Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add docker support #79

Closed
wants to merge 1 commit into from
Closed

Add docker support #79

wants to merge 1 commit into from

Conversation

dosten
Copy link
Contributor

@dosten dosten commented Jul 6, 2015

Hi!

This PR adds Docker support, so, anyone with a Docker installation can run $ docker-compose up to run the application :)

@javiereguiluz
Copy link
Member

@dosten thanks for sending this improvement. Before merging it, I'll wait for someone with Docker experience to review it. Thanks.

@mykiwi
Copy link

mykiwi commented Jul 7, 2015

I'm agree to add docker.

I think it will be nicer if Dockerfiles files were in a docker (or .docker) directory.

I use a different Dockerfile to have no warning/error while running app/check.php, and also use the port 80:

FROM php:5.6

RUN apt-get update && \
    apt-get install -y libicu-dev g++ && \
    docker-php-ext-install intl mbstring opcache && \
    apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* && \
    echo "date.timezone = UTC\nshort_open_tag=Off" >> /usr/local/etc/php/conf.d/symfony.ini

VOLUME  /srv
WORKDIR /srv

EXPOSE 80

ENTRYPOINT ["app/console"]
CMD ["server:run", "0.0.0.0:80"]

In the readme, we should also explain how use the app/console with docker-compose:
docker-compose run --rm web app/console

And maybe we should rename the web service (in docker-compose.yml) by symfony.

@javiereguiluz
Copy link
Member

@romqin thanks for proposing this alternative! Now I'll wait for other Docker users to comment about which is the best file to use and about @romqin's idea to create a docker directory. Thanks.

@bocharsky-bw
Copy link
Contributor

The Mac users may have problems to use it (there are permissions problem for cache dir that not fixed yet, only workaround exists now).
I think the best solution is to use Vagrant with NFS files sharing to avoid it, but that way we get possible problems with Windows users because they haven't NFS sharing.

So I don't think that add Docker is a good idea, it will not be cross platform because there are a lot of custom solutions and workaround for different OS.

@mykiwi
Copy link

mykiwi commented Jul 7, 2015

@bocharsky-bw I'm on Mac and I don't have this problems. You can set the option -u with the user uid.
Kitematic (or boot2docker, but less user friendly) should works fine for windows.

@bocharsky-bw
Copy link
Contributor

@romqin Do you think it will be a right solution? It all will be need to add to docs, it's too specific for separate OS. And what about Windows users?

Anyway I vote to move this Docker solution to the separate repository as it too specific as for me.

@Nicofuma
Copy link

Nicofuma commented Jul 7, 2015

For the cache and logs, what we can do is to add a volume container to hold them. This way we will not have any perm issue (but if you want to see the logs you will have to use docker exec)

EDIT: actually no need for another container, just define the volumes (see @jderusse comment below)

WORKDIR /app

ENTRYPOINT ["./app/console"]
CMD ["server:run", "0.0.0.0:8000"]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, use the default http port 80, if the end user want to map it with something else, he can do it with -p 8000:80

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I vote for 8000 port because it used as a default port for app/console server:run command.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

server:run is designed to run on the developer's machine which probably have an other webserver listening on port 80.
This issue does not exists in a containers.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it makes sense. However, I think almost every developer should change 80 to something different because he most probably also has an installed server which already listening 80 on host machine. So maybe better left 8000 for container?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also think that the server should be run on port 80. If it is already used on the host, the port must be changed in the docker-compose.yml

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some developpers don't use the port forwarding to the Host.
But use DNS to directly access the container. It will be great to use the default port.

@killerwolf
Copy link

Is the Dockerfile for demo or dev purposes ?

@javiereguiluz
Copy link
Member

Do you think it's possible to agree on some common Docker configuration to merge this? Thanks!

@bocharsky-bw
Copy link
Contributor

I plan to use Dockerfile for dev purpose too.

@@ -0,0 +1,11 @@
FROM php:5.6

RUN echo "date.timezone = UTC" > /usr/local/etc/php/conf.d/date.ini
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer this:

RUN echo "date.timezone = UTC"  >> /usr/local/etc/php/conf.d/symfony.ini && \
    echo "short_open_tag = off" >> /usr/local/etc/php/conf.d/symfony.ini && \
    apt-get update && \
    apt-get install -y libicu-dev && \
    docker-php-ext-install intl mbstring opcache && \
    apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

It's for the app/check.php and also to add opcache

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose that libicu-dev needs for intl, right? But why we need g++ here?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed. g++ is not required, I removed it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about xdebug? Could we install it here?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👎

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about to create docker/php/symfony.ini file and COPY it into the container instead of echoing with RUN command?

@javiereguiluz
Copy link
Member

Should we close this issue as "won't fix for now" ... or do you think we are close to some agreement? Thanks.

@frastel
Copy link
Contributor

frastel commented Oct 19, 2015

Also I am a big fan of Docker (I hosted a Docker Workshop on the latest Symfony Live in Berlin where I created different Docker environments for the Symfony Demo App), I am of the mind that it's the wrong approach for providing a Docker setup within this project.
When we start to add the Docker solution than we also need the Vagrant, Puppet, Ansible way or whatsoever. The project would get bound and messed up with provisioning solutions. In my opinion the project should be focused on Symfony and nothing more.
Besides: The proposed Docker solution is too limited. It only creates an environment for PHP 5.6. Other possible and compatible environments are ignored.

In addition: It would be better to provide those information in additional projects, like "symfony-demo-docker", "symfony-demo-vagrant" or a generic one "symfony-demo-provisioning".

@theofidry
Copy link

@frastel 👍

Providing a VM, Docker, Vagrant or whatever will just add complexity to the project, is not really Symfony focused (although it makes sense of course, but it's out of the scope of this project IMO) and make it harder for newbies.

@javiereguiluz
Copy link
Member

Just asking: would it make sense to write some cookbook about "Symfony + Docker" and use the "Symfony Demo" as an example?

@bocharsky-bw
Copy link
Contributor

I'm 👍 for this cookbook! It'll be very interesting and keep a lot of time of other devs, IMO.

@theofidry
Copy link

Just asking: would it make sense to write some cookbook about "Symfony + Docker" and use the "Symfony Demo" as an example?

IMO it would be better to take a brand new Symfony standard rather. It would be easier to maintain.

@bocharsky-bw
Copy link
Contributor

@frastel It's something that I meant here, but you describe this much better 👍

@dosten
Copy link
Contributor Author

dosten commented Oct 30, 2015

@frastel 👍 I'm in favor of a cookbook for "Symfony + Docker" so closing..

@dosten dosten closed this Oct 30, 2015
@ivoba
Copy link

ivoba commented Jan 24, 2016

where does this discussion continue now exactly? can you post a link to the "cookbook", pls.

@bocharsky-bw
Copy link
Contributor

@ivoba I think this in the docs repo now symfony/symfony-docs#4055

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

10 participants