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

[project-base] adding php.ini to image is now done only in dockerfiles #497

Merged
merged 4 commits into from
Sep 26, 2018

Conversation

MattCzerner
Copy link
Contributor

@MattCzerner MattCzerner commented Sep 21, 2018

Q A
Description, reason for the PR Mounting of php.ini using volumes does not apply the changes without manually restarting the php-fpm process. Because of that, the mounting is not used anymore and instead it is added using COPY during Docker image build. That way, if anything changes in php.ini, it is added to the image during build and loaded when the container starts.
New feature No
BC breaks No
Fixes issues ...
Standards and tests pass Yes
Have you read and signed our License Agreement for contributions? Yes

@MattCzerner
Copy link
Contributor Author

Php.ini is mounted there but it does not apply changes if you change something. I dont think that php.ini configuration isnt something that should be mounted, it is changed really rarely and it could improve performance for docker-sync.

In kubernetes, there is not any reason to make it volume.

@PetrHeinz
Copy link
Contributor

I agree, that there is no reason to mount the config files in Kubernetes manifests. I would remove it from there, just as you suggest.


I would argue that the config files should behave consistently in Docker Compose during development - look at https://github.com/shopsys/shopsys/blob/v7.0.0-beta1/docker/conf/docker-compose.yml.dist and notice that there are postgres.conf, nginx.conf, php-ini-overrides.ini and another php-ini-overrides.ini for each microservice.

Some of these mounts are necessary because official Docker images are used (and we don't want to create our own Dockerfile atm). Some of these mounts are redundant - they overwrite already copied files during build. Mounting of php-ini-overrides.ini inside the php-fpm container is necessary as we don't copy the file into the image directly, even though we build the image ourselves.

Personally, I think that from the point of view of a developer using monorepo, all config files should behave the same, or at least it should be clear what happens when.


This is a valuable insight for me in context of our planned mutli-stage Docker image building - we should probably make this behavior consistent and documented. Maybe use mounts for local development (with both the source codes and the configs NOT copied into the image), no mounting on our CI (as they are copied into the image) and no mounting to the product images? We might even need to build our own Docker images of services such as nginx, just because of having more control over tagging and having the config files copied inside them - or is the config-mounting in Kubernetes OK for production images?

@MattCzerner
Copy link
Contributor Author

Okay, ur right in case of consistency. I dont see really the problem in having 2 scenarios.

1st - our dockerimages, we add it using dockerfile and not mount it at all, i think that there is no point, even if it is mounted it is not automatic to load this configuration into running php process.

2nd - 3rd party dockerimages, it would be wierd to create dockerfile just to add configurations.

But i guess thats different problem then just removing volumes. Should i just delete mounts of kubernetes and mount of configs in docker-compose let be, since it will be decided in multistage US?

@PetrHeinz
Copy link
Contributor

I would be perfectly fine with both solutions: either just remove the redundant Kubernetes mounts, or remove all config mounts from our docker images and add the COPY instruction to both our php-fpm Dockerfiles (which would make its Kubernetes mount redundant as well).

Copy link
Contributor

@PetrHeinz PetrHeinz left a comment

Choose a reason for hiding this comment

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

You still mount the .ini files in project-base's docker-compose.ymls, eg. here, remove it there as well please.

Should we update the UPGRADE.md? Users will need to rebuild their php-fpm container for it to contain, but only if they manually remove the config mounts, so it should be backwards-compatible; the upgrade step might be a bit confusing for some...

How shall we test it?

@@ -35,8 +35,7 @@ services:
volumes:
- shopsys-framework-sync:/var/www/html
- shopsys-framework-vendor-sync:/var/www/html/vendor
- shopsys-framework-web-sync:/var/www/html/project-base/web
- ./project-base/docker/php-fpm/php-ini-overrides.ini:/usr/local/etc/php/php.ini:delegated
- shopsys-framework-web-sync:/var/www/html/project-base/web:delegated
Copy link
Contributor

Choose a reason for hiding this comment

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

why delegated? probably typo

# allow configuring the GitHub OAuth token
ARG github_oauth_token
RUN composer config -g github-oauth.github.com $github_oauth_token

# hirak/prestissimo makes the install of Composer dependencies faster by parallel downloading
RUN composer global require hirak/prestissimo


Copy link
Contributor

Choose a reason for hiding this comment

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

probably a mistake

@MattCzerner
Copy link
Contributor Author

Okay i deleted mounting of php-ini of php-fpm container too.

Now it is only possible to reload php.ini configuration by build of dockerimage.

Copy link
Contributor

@PetrHeinz PetrHeinz left a comment

Choose a reason for hiding this comment

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

There are still some issues, please, address them and test it locally.

Also, I've noticed you've changed 4 out of 6 docker-compose templates. Please, take another look at it.

@@ -35,8 +35,7 @@ services:
volumes:
- shopsys-framework-sync:/var/www/html
- shopsys-framework-vendor-sync:/var/www/html/vendor
- shopsys-framework-web-sync:/var/www/html/project-base/web
- ./project-base/docker/php-fpm/php-ini-overrides.ini:/usr/local/etc/php/php.ini:delegated
- shopsys-framework-web-sync:/var/www/html/project-base/web:delegated
Copy link
Contributor

Choose a reason for hiding this comment

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

the delegated is probably a typo, please fix it or explain it

@@ -4,7 +4,7 @@ services:
image: postgres:10.5-alpine
container_name: shopsys-framework-postgres
volumes:
- ./project-base/docker/postgres/postgres.conf:/var/lib/postgresql/data/postgresql.conf:delegated
- ./project-base/docker/postgres/postgres.conf:/var/lib/postgresql/data/postgresql.conf
Copy link
Contributor

Choose a reason for hiding this comment

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

the removal of delegated is probably a mistake

@@ -4,7 +4,7 @@ services:
image: postgres:10.5-alpine
container_name: shopsys-framework-postgres
volumes:
- ./docker/postgres/postgres.conf:/var/lib/postgresql/data/postgresql.conf:delegated
- ./docker/postgres/postgres.conf:/var/lib/postgresql/data/postgresql.conf
Copy link
Contributor

Choose a reason for hiding this comment

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

this makes me think there is a reason for the changes - why are you doing this?

@@ -60,6 +60,9 @@ ENV LC_ALL=en_US.utf8 LANG=en_US.utf8 LANGUAGE=en_US.utf8
# overwrite the original entry-point from the PHP Docker image with our own
COPY docker-php-entrypoint /usr/local/bin/

# copy php.ini configuration
COPY project-base/docker/php-fpm/php-ini-overrides.ini /usr/local/etc/php/php.ini
Copy link
Contributor

Choose a reason for hiding this comment

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

this assumes that the Docker build context is the root of the monorepo, right? But the COPY above assumes the actual context is the docker directory. Both can't be true.

@PetrHeinz
Copy link
Contributor

Please, rename the PR to reflect the new changes and our rules about package-tagging.

@MattCzerner MattCzerner changed the title Deleted unnecessary mounting of php.ini configuration [shopsys] Deleted unnecessary mounting of php.ini configuration Sep 25, 2018
- all php.ini configurations are added to image during dockerimage build
@MattCzerner
Copy link
Contributor Author

I did it by global find and replace function and i didnt see the delegated options.

I rebased it and squashed it into one lucid commit. Also I got a question about upgrade notes. Because you should copy new version of docker-compose.yml but is not essential for application to work.

So do we write it into UPGRADE.md or not?

Copy link
Contributor

@PetrHeinz PetrHeinz left a comment

Choose a reason for hiding this comment

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

In the UPGRADE.md there should an explanation that we changed the way php.ini config files are used in the containers - that they are copied during the image build instead of mounting it. I would inform the users that they can remove all the volumes mentioning php-ini-overrides.ini (just as in the original template), but they will have to rebuild the image for any changes to take place from now on.

Please, change the name of the PR to fully reflect this change. The word unnecessary should definitely not be there, as it was necessary until you've added the COPY instruction in php-fpm Dockerfile.

Please, provide reasons for this change in the description - without them we can see a new PR in a few months named "Deleted unnecessary copying of php.ini configuration" with a reason "configuration is added there using volume mounts". Please, clarify why is this approach better.

@MattCzerner MattCzerner changed the title [shopsys] Deleted unnecessary mounting of php.ini configuration [shopsys] adding php.ini to image is now done only in dockerfiles Sep 26, 2018
@MattCzerner
Copy link
Contributor Author

@PetrHeinz I updated name of PR and description, also i have added record to UPGRADE.md if you would find any gramatical mistake, you can override it.

@MattCzerner MattCzerner changed the title [shopsys] adding php.ini to image is now done only in dockerfiles [project-base] adding php.ini to image is now done only in dockerfiles Sep 26, 2018
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.

2 participants