Skip to content

Refactor PHP configuration handling to support runtime environment variables (dynamic ini generation) #39

@g0blin79

Description

@g0blin79

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

  • The image regenerates application.ini and opcache.ini at container startup, not at build time
  • Changing environment variables in docker run or docker-compose.yml updates PHP configuration as expected
  • The new entrypoint wrapper correctly forwards all arguments to the original entrypoint
  • Documentation is updated to reflect the new behaviour

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions