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

Discussion: how to best use php.ini-production and php.ini-development #873

Closed
claycogg opened this issue Jul 30, 2019 · 3 comments
Closed
Labels
question Usability question, not directly related to an error with the image

Comments

@claycogg
Copy link

Hello,

I am using the php7.3 image to serve a php website (as most do). We need to swap between the 2 .inis depending on if we are running in a development environment or production environment.

How is this typically handled? Both files are in the container so is there some strategy for changing which is used at run-time? The README has limited input on the subject and understanding the best way to use both seems to require more knowledge than is in the README.

It is strongly recommended to use the production config for images used in production environments!

The default config can be customized by copying configuration files into the $PHP_INI_DIR/conf.d/ directory.

I have a few ideas, but could use some help.

Proposal #1

The first idea is to make 2 containers and run the following with ENVIRONMENT set differently. This lets us continue to manage a single Dockerfile, but now we have 2 images.

RUN mv "$PHP_INI_DIR/php.ini-${ENVIRONMENT}" "$PHP_INI_DIR/php.ini"

This isn't the best solution in my eyes as it means managing 2 different containers that differ by a single file. So we thought...

Proposal #2

What if we extend the entry point? Instead of just starting apache we would also run the move command, and provide ENVIRONMENT at runtime. The downside of this is complicating the entrypoint by increasing the complexity of the command it runs, which is not typically how entrypoint is used.

Proposal #3

Create 2 different directories, one for production and development and use apache's PHPhIniDir to set where apache looks for php.ini. Then we can provide an environment variable at runtime to change where Apache looks, allowing us to have a single container with both configurations. I think this is the best option.

Thank you for any input you have on this problem!

@wglambert
Copy link

Maintaining separate Dockerfiles to add RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini" is easy to automate using Docker Hub's automated builds and repository links

Similar to docker-library/haproxy#59 (comment)

@wglambert wglambert added the question Usability question, not directly related to an error with the image label Aug 1, 2019
@wglambert
Copy link

Additionally you could keep local copies of the files and then in your docker-compose.yml or docker run lines you mount the corresponding production/development .ini to /usr/local/etc/php/php.ini

@wglambert
Copy link

I'm going to close since users browsing the issues don't seem interested and this isn't really a substitute for resources like the Docker Community Forums, Docker Community Slack, or Stack Overflow

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Usability question, not directly related to an error with the image
Projects
None yet
Development

No branches or pull requests

2 participants