Overview
Our current base images writes PHP configuration files (application.ini and opcache.ini) at build time, embedding values from environment variables such as:
- PHP_MEMORY_LIMIT
- PHP_MAX_EXECUTION_TIME
- PHP_UPLOAD_MAX_FILESIZE
- OPCACHE_ENABLED
- OPCACHE_MEMORY_CONSUMPTION
etc.
Because the .ini files are generated during image build, changing these variables at runtime (through docker run -e, docker-compose.yml, Kubernetes env: blocks, etc.) has no effect on the running container.
Problem
Users expect to be able to configure PHP behaviour dynamically at runtime, e.g.:
environment:
OPCACHE_ENABLED: "0"
PHP_MEMORY_LIMIT: "1024M"
However, since the .ini files are baked into the image, PHP keeps using the build-time values, which makes the configuration inflexible and inconsistent with common container best practices.
Proposal
Refactor the way PHP configuration is generated:
- Remove build-time generation of:
-- /usr/local/etc/php/conf.d/application.ini
-- /usr/local/etc/php/conf.d/opcache.ini
- Introduce a runtime entrypoint wrapper (e.g.
docker-php-entrypoint-env.sh) that:
-- reads current environment variables
-- dynamically generates the above .ini files on container start
-- finally delegates to the official docker-php-entrypoint
- Ensure all default values remain compatible with existing behaviour, but allow full override via environment variables.
Acceptance criteria
Overview
Our current base images writes PHP configuration files (
application.iniandopcache.ini) at build time, embedding values from environment variables such as:etc.
Because the
.inifiles are generated during image build, changing these variables at runtime (throughdocker run -e,docker-compose.yml, Kubernetesenv:blocks, etc.) has no effect on the running container.Problem
Users expect to be able to configure PHP behaviour dynamically at runtime, e.g.:
However, since the
.inifiles are baked into the image, PHP keeps using the build-time values, which makes the configuration inflexible and inconsistent with common container best practices.Proposal
Refactor the way PHP configuration is generated:
--
/usr/local/etc/php/conf.d/application.ini--
/usr/local/etc/php/conf.d/opcache.inidocker-php-entrypoint-env.sh) that:-- reads current environment variables
-- dynamically generates the above .ini files on container start
-- finally delegates to the official
docker-php-entrypointAcceptance criteria
application.iniandopcache.iniat container startup, not at build timedocker runordocker-compose.ymlupdates PHP configuration as expected