-
Notifications
You must be signed in to change notification settings - Fork 331
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 setup #242
Add Docker setup #242
Conversation
9f5253c
to
5176bae
Compare
5176bae
to
bdac10c
Compare
app/config/config.yml
Outdated
host: '%database_host%' | ||
port: '%database_port%' | ||
dbname: '%database_name%' | ||
user: '%database_user%' | ||
password: '%database_password%' | ||
driver: pdo_mysql |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not keep that parameter?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because it cannot be used in any meaningful way. 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reverted this change for now.
@@ -10,13 +9,13 @@ parameters: | |||
|
|||
mailer_transport: '%env(SYLIUS_MAILER_TRANSPORT)%' | |||
mailer_host: '%env(SYLIUS_MAILER_HOST)%' | |||
mailer_port: '%env(SYLIUS_MAILER_PORT)%' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we extract this change to another PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure. But we need it here...
@@ -52,6 +52,9 @@ watchShop.description = 'Watch shop asset sources and rebuild on changes.'; | |||
export const build = gulp.parallel(buildAdmin, buildShop); | |||
build.description = 'Build assets.'; | |||
|
|||
export const watch = gulp.parallel(watchAdmin, watchShop); | |||
watch.description = 'Watch asset sources and rebuild on changes.'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we extract this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure. But we need it here...
.travis.yml
Outdated
- docker-compose pull --ignore-pull-failures | ||
- docker-compose build --pull | ||
- docker-compose up -d | ||
- sleep 60 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No idea how to solve that better, just leaving a comment so it's more visible
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm sure there are more fancy ways, but this is the simplest way that works. 😆
@@ -0,0 +1,108 @@ | |||
version: '3.4' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These two different files for dev and prod would be hard to keep in sync (eg. this version differs).
@jacquesbh mentioned this on Slack on Friday:
yes. And it's just a step away to create a
docker-compose.traefik.yml
and explain thatdocker-compose -f docker-compose.yml -f docker-compose.traefik.yml
can be use
Can we use an architecture like this for those extra containers (eg. mailhog, nodejs)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not just about additional services...
@@ -0,0 +1,14 @@ | |||
apc.enable_cli = 1 | |||
date.timezone = ${PHP_DATE_TIMEZONE} | |||
opcache.enable_cli = 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Opcache in CLI might cause some issues during development
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Such as? :D
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Once we had an issue when phpspec was running unexisting spec which had been removed before, the issue vanished after we disabled opcache.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be honest, that sounds like a misconfiguration of OpCache, so we should be fine here.
The Docker configurations for the Sylius project should not be included in the standard version. The reasons that I consider main are:
If Docker is included in the Standard version, the configurations of the Vagrant configured for Sylius are also included. In Sylius/Sylius#9414 @stefandoorn adds the following: "can it still be a separate repo? I prefer to have my infra stuff in separate repo, instead of combined with the application itself (SRP). Besides that, not everyone likes or is using Docker, so for these it's not needed to have it in the same repo." Matter of which I totally agree. So, all efforts to achieve a good configuration of Docker for Sylius (https://github.com/Sylius/docker) should focus on the repository that already exists and keep it separate. |
@nietzscheson We've already had that discussion in Sylius/Sylius#9414 and on Slack. I don't see the need to bring it up again here... |
So is. But this is where the code merges and I see that you want to reiterate what precisely was already discussed on the channel. I just want to make clear my position... |
bdac10c
to
9975227
Compare
Personally, I have no preference between having the Docker setup in Sylius/Sylius-Standard or as a separate repository. Though I have a question: how can one re-use this setup when trying to contribute to Sylius/Sylius? through copy-paste of the docker and docker compose files? Also, certain services are missing:
Shouldn't we include these too? |
One way is to mount the host directory into, say,
Could be added in other PR(s) |
Second thing I want to bring under your attention: running commands under the root user inside containers is going to mess up permissions on the files on the host. Especially on development mode, I find it better to use another user inside the container that has UID and GID mapped with the one from the host. On the setup I generally use, I have the following in the docker file:
This way, whenever entering the container, I make sure I use the $APPLICATION_USER and everything is OK. Also, my understanding is that running commands inside docker containers as root may imply a security risk:
|
can you offer me an example on how one can use this docker setup to test a modification it brought to the Sylius/Sylius vendor file? |
It's basically on its own, not as a vendor package. Just |
As for running as root in the container, it's as we've discussed on Slack: there is no good solution that I'm aware of. But we could perhaps add support for running with a different uid/gid in the entrypoint. |
Switching user in the Dockerfile cannot work, because the built image has to be portable (and redistributable). |
User rightsFor the user rights we have this: Makefile: export USER_UID=$(shell id -u)
example:
docker-compose ps In our Dockerfiles: # Use www-data user
ARG USER_UID=1000
RUN usermod -u $USER_UID www-data By default In our services:
my-container:
build:
context: my-container/
args:
USER_UID: ${USER_UID} This way, by using a simple variable, we avoid a lot of problems. We don't have a makefile yet. Why not adding one? It's a good way to improve the developers flow. Missing containersThe missing containers are for testing purpose. This is why I propose to use a |
@jacquesbh Anything that involves setting uid/gid in the Dockerfile is not a solution, because it'd result in an image that's not portable / redistributable. |
This is portable, working on Windows, Linux and macOS. We use it everyday for many projects. So… |
Let's keep this first PR small? |
No, I'm talking about the image being portable. It should be able to be used by any user regardless of their uid/gid on the host, without having to rebuild the image. |
We should support running with arbitrary uid/gid (via the docker-library/mysql#397 (comment) |
9975227
to
0104725
Compare
I hope we could have this PR merged soon, then others could help to make things better. |
0104725
to
5a70148
Compare
Thank you, Teoh, let's make it the best Docker ever for 1.3 release 🎉 |
Replaces #232