Code Monkey home page Code Monkey logo

symfony-docker's Introduction

Symfony Docker Edition by Latest Stable Version

The unofficial Symfony Docker Edition – by @drgomesp

http://drgomesp.github.io/symfony-docker/

This is an unofficial, open-source and community-driven boilerplate for Symfony projects that run on Docker. It's an attempt of standardizing and making it easier to bootstrap Symfony applications ready for development and production environments. The main tools used are Symfony, Docker and Docker Compose. Other things included are:

  • PHP 7.1 + PHP-FPM
  • Nginx
  • Xdebug
  • Opcache

Table of Contents

Installation

Before anything, you need to make sure you have Docker properly setup in your environment. For that, refer to the official documentation for both Docker and Docker Compose. Also, if you're developing on Mac or Windows – yeah, maybe that's the case –, make sure you have Docker Machine properly setup.

This project depends on having jwilder/nginx-proxy running. This is a reverse proxy container that will allow having multiple projects running on port 80.

Build and run the containers:

docker-compose up -d --build

Once that's done, you should be able to access the application on the IP that docker (or Docker Machine) is running at.

FAQ

Coming soon...

Enjoy!

symfony-docker's People

Contributors

aferrandini avatar angyvolin avatar drgomesp avatar gabrielsch avatar henriquemoody avatar ivoba avatar mathewpeterson avatar sergeyklay avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

symfony-docker's Issues

Docker-compose run composer install failed

Hi,

On my Ubuntu and on my Mac OS X, the next command failed :
docker-compose run symfony-docker composer --prefer-source install

Error message is "ERROR: No such service symfony-docker"

However the command docker-compose ps show three services (api-mariadb, api-memcached and symfony-docker).

ship a bundle

I'm sorry if this is a stupid question, because I don't know perfectly how docker and Symfony can integrate, but:

can't this be a bundle?

I mean: I won't use this as start for a Symfony project, because I want to start from composer create-project or whatever, but I'd surely use this as a bundle.

Once I start a project based on this boilerplate, I cannot update it, to have the latest features. But with a bundle, this can be done. And of course, you could ship also the Symfony Docker Edition with this bundle as required.

Some desired specs:

  • configurable (eg. I want to use a local mysql for tests, but for the prod container I want to connect to the real database server; or I want to choose between apache and nginx)
  • cli commands

Update installation/usage instructions - or am I doing something wrong?

git clone https://github.com/drgomesp/symfony-docker
cd symfony-docker
# README says we need jwilder/nginx-proxy so...
docker run -d -p 80:80 -v /var/run/docker.sock:/tmp/docker.sock:ro jwilder/nginx-proxy

docker-compose up -d --build

At this point I realise that composer install hasn't been run so:

docker-compose run symfony-docker composer --prefer-source install

Going to http://localhost/ gives me 503 Service Temporarily Unavailable.

Going to http://localhost:81/ gives me Unable to create the cache directory (/app/var/cache/dev)

Following the instructions at the link in the README also fails in a similar way:

http://drgomesp.github.io/symfony-docker/

Installing using composer:

composer create-project drgomesp/symfony-docker
cd symfony-docker 
docker-compose up -d

Am I doing something wrong? Or is the readme outdated?

cache permission issue

I run the containers and did make the composer install but the permissions for the cache files are not properly set and i get:

Failed to write cache file "/app/var/cache/dev/classes.php".

This problem is one of the main painpoints of using symfony with docker, imho, at least in a dev env.
I've been struggling with that for a while now and maybe we can find a solution here together.

You can read my struggle here: https://stackoverflow.com/questions/34949083/symfony-docker-permission-problems-for-cache-files.

docker-bundle - Script Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache handling the post-install-cmd event terminated with an exception

Hi, after cloning repo, made composer install and passing by the parameters I got following error.

[RuntimeException]                                                                                                                                                             
  An error occurred when executing the "'cache:clear --no-warmup'" command:                                                                                                      
  PHP Fatal error:  Uncaught Symfony\Component\Debug\Exception\ClassNotFoundException: Attempted to load class "DockerBundle" from namespace "Drgomesp\DockerBundle".            
  Did you forget a "use" statement for another namespace? in /var/www/html/docker/01-symfony-docker/app/AppKernel.php:19                                                         
  Stack trace:      

  #0 /var/www/html/docker/01-symfony-docker/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php(396): AppKernel->registerBundles()                                
  #1 /var/www/html/docker/01-symfony-docker/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php(114): Symfony\Component\HttpKernel\Kernel->initializeBundles()    
  #2 /var/www/html/docker/01-symfony-docker/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Console/Application.php(68): Symfony\Component\HttpKernel\Kernel->boot()   
  #3 /var/www/html/docker/01-symfony-docker/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php(117): Symfony\Bundle\FrameworkBundle\Console\Application->doRu  
  n(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Consol in /var/www/html/docker/01-symfony-docker/app/AppKernel.php on line 19   

command : composer require drgomesp/docker-bundle gives
`

Installation failed, reverting ./composer.json to its original content.

                                                                                                                          
  [Composer\DependencyResolver\SolverProblemsException]                                                                   
    Problem 1                                                                                                             
      - Installation request for drgomesp/docker-bundle dev-master -> satisfiable by drgomesp/docker-bundle[dev-master].  
      - drgomesp/docker-bundle dev-master requires symfony/yaml ^3.1 -> no matching package found.                        
  Potential causes:                                                                                                       
   - A typo in the package name                                                                                           
   - The package is not available in a stable-enough version according to your minimum-stability setting                  
     see <https://getcomposer.org/doc/04-schema.md#minimum-stability> for more details.                                   
  Read <https://getcomposer.org/doc/articles/troubleshooting.md> for further common problems.  

`
Thank you in advance for your help...

Git, pdo and pdo_mysql are missing ?

Hello,

I do not know if I am alone in this case but this stack is not usable out of the box (tested on windows).

  • Impossible to do a proper composer install because of git missing on the web image.
  • When trying to connect to mariadb there is an error yelling that php could not find driver.

After adding git and installing pdo and pdo_mysql I was able to create my database with symfony's console. But, I still have permissions problems...

Did I do something wrong or missed something ? Or is this "normal" ?

Thanks.

SSL cert support

It would be great if symfony-docker supported an easy way of installing (or generating) SSL certs, and perhaps an option for always redirecting to HTTPS.

A first level solution might simply be pre-set names/directory(s) for the cert files.

A second stage solution might be a command for generating a CSR, and a self-signed cert for development.

Bonus: connect to Let's Encrypt and generate real certs.

Unable to build due to incorrect path

I've converted my Symfony 2.6 project into the symfony-docker format today.
I wanted to run php bin/console docker:compose:build but I've got the following error.

ERROR: build path C:\Development\Code\Web\rwslinkman\vendor\drgomesp\symfony-docker-bundle\Resources\config\docker\vendor\symfony-docker\docker-bundle\Resources\config\docker\nginx
either does not exist, is not accessible, or is not a valid URL.

The command cannot find the config files because the path is incorrect. I've tried to look for a "relative path" setting but no luck.
Is there something I've missed in the configuration?

Symfony Docker Bundle

Hello ,

i've clone your project , but i figure out that the docker symfony bundle dosen't exsit wchich i can't be able to finish your tuto

/bin/sh: 1: apt-install: not found

Tried to install it and this is what I am getting

app uses an image, skipping
Building php
Step 1 : FROM php:5.6-fpm
 ---> a0e78ea4a88b
Step 2 : MAINTAINER Mathew Peterson <[email protected]>
 ---> Using cache
 ---> d9cfcc87bb6d
Step 3 : RUN usermod -u 1000 www-data
 ---> Using cache
 ---> 0fae479d2dd6
Step 4 : COPY bin/* /usr/bin/
 ---> Using cache
 ---> c1375bf072a0
Step 5 : RUN chmod +x -R /usr/bin/*
 ---> Using cache
 ---> d50996e9acde
Step 6 : COPY conf/php.ini /usr/local/etc/php/conf.d/
 ---> Using cache
 ---> 67d3eca598a0
Step 7 : COPY conf/pool.conf /usr/local/etc/php/
 ---> Using cache
 ---> 7adfa9d7e927
Step 8 : WORKDIR /app
 ---> Using cache
 ---> c7e506abf29a
Step 9 : RUN apt-install     apt-utils     less     libssl-dev     git     zip     libfreetype6-dev     libjpeg62-turbo-dev     libpng12-dev
 ---> Running in f83076cf5265
/bin/sh: 1: apt-install: not found
ERROR: Service 'php' failed to build: The command '/bin/sh -c apt-install     apt-utils     less     libssl-dev     git     zip     libfreetype6-dev     libjpeg62-turbo-dev     libpng12-dev' returned a non-zero code: 127

dont expose db port

I run docker nativly on ubuntu and also have mysql running on the host.
When exposing the port 3306 of MariaDB this will collide with the host DB.

Error starting userland proxy: listen tcp 0.0.0.0:3306: bind: address already in use

So i propose to not expose the port but keep it internal:
by replacing:

ports:
   - "3306:3306"

to:

ports:
  - 3306

As the tutum image already allows remote connections by

RUN sed -i -r 's/bind-address.*$/bind-address = 0.0.0.0/' /etc/mysql/my.cnf

its still possible to use f.e. workbench to check your database by using the ip as host.
You can get the ip of the container with:

docker inspect --format '{{ .NetworkSettings.IPAddress }} {{ .Name }}' $(docker ps -q)

Support Apache server version

As you are thinking about having a PHP7 version in a different branch, we can have a separate version with Apache instead of NGINX.

Error while clearing the cache

First of all, nice job for this Symfony Docker edition.
Then, I tried to clear symfony's cache by using this command:

$ docker-compose run web php bin/console cache:clear

But all I got is this error:

  [Symfony\Component\Filesystem\Exception\IOException]       
  Failed to remove directory "/app/var/cache/de~/doctrine".  


cache:clear [--no-warmup] [--no-optional-warmers] [-h|--help] [-q|--quiet] [-v|vv|vvv|--verbose] [-V|--version] [--ansi] [--no-ansi] [-n|--no-interaction] [-e|--env ENV] [--no-debug] [--] <command>

I'm not sure if that's a real issue or if I'm doing it wrong...

'mysql-client' has no installation candidate

Hello

When I try to run docker-compose up -d --build I am getting an error

Get:1 http://security-cdn.debian.org/debian-security buster/updates InRelease [39.1 kB]
Get:2 http://cdn-fastly.deb.debian.org/debian buster InRelease [118 kB]
Get:4 http://security-cdn.debian.org/debian-security buster/updates/main amd64 Packages [53.4 kB]
Get:3 http://cdn-fastly.deb.debian.org/debian buster-updates InRelease [46.8 kB]
Get:5 http://cdn-fastly.deb.debian.org/debian buster/main amd64 Packages [7897 kB]
Fetched 8154 kB in 18s (457 kB/s)
Reading package lists...
Reading package lists...
Building dependency tree...
Reading state information...
Package mysql-client is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package 'mysql-client' has no installation candidate
ERROR: Service 'app' failed to build: The command '/bin/sh -c apt-get update && apt-get install -y zip

then the image won't start when I look at docker ps -a

Support PHP 7 in a different branch

We need to support PHP 7 with all the same features in a different branch, so that users can choose which version they want to use for their projects.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.