You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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...
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.
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!
The text was updated successfully, but these errors were encountered:
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
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
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.
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!
The text was updated successfully, but these errors were encountered: