diff --git a/fpm/Dockerfile b/fpm/Dockerfile index cea37c4..7f72370 100644 --- a/fpm/Dockerfile +++ b/fpm/Dockerfile @@ -8,6 +8,13 @@ RUN apk --update --no-cache add \ COPY conf.d/50_fpm.ini /etc/php/conf.d/50_fpm.ini COPY php-fpm.conf /etc/php/php-fpm.conf +# Owned by skpr so the live configuration can be replaced in a running +# container, which is the point of it: the change lands without restarting +# PHP-FPM. +RUN mkdir -p /etc/compass && \ + chown skpr:skpr /etc/compass +COPY --chown=skpr:skpr compass/config.yml /etc/compass/config.yml + # Ensure the FPM configuration directory is empty. # Create an empty file to ensure there are no warnings. RUN rm -f /etc/php/php-fpm.d/*.conf && \ @@ -28,15 +35,17 @@ ENV PHP_FPM_PORT=9000 \ PHP_FPM_MAX_REQUESTS=500 \ PHP_FPM_REQUEST_TIMEOUT=60 +# Startup configuration for the Compass extension. +# Everything else lives in /etc/compass/config.yml and is reloaded live. +ENV COMPASS_ENABLED=false \ + COMPASS_CONFIG_FILE=/etc/compass/config.yml + # Run the test stage to verify the image. FROM base AS test COPY --from=ghcr.io/goss-org/goss:latest /usr/bin/goss /usr/bin/goss ADD goss.yml /tmp/goss.yml RUN goss --gossfile /tmp/goss.yml validate -ENV COMPASS_ENABLED=false -ENV COMPASS_FUNCTION_THRESHOLD=1000000 - # The final stage which is used to run the image. FROM base AS run CMD ["php-fpm", "-F"] diff --git a/fpm/compass/config.yml b/fpm/compass/config.yml new file mode 100644 index 0000000..3da225e --- /dev/null +++ b/fpm/compass/config.yml @@ -0,0 +1,10 @@ +# Live configuration for the Compass PHP extension. +# +# Running PHP processes pick changes up within five seconds. Nothing needs to be +# restarted, and nothing here is read while no tracer is attached. + +# Only report function calls slower than this, in nanoseconds. +function_threshold: 1000000 + +# Stops all probing while it is true, leaving the extension loaded. +suspend: false diff --git a/fpm/goss.yml b/fpm/goss.yml index d8d6863..43226a7 100644 --- a/fpm/goss.yml +++ b/fpm/goss.yml @@ -11,3 +11,18 @@ command: exit-status: 0 stdout: contain-substring: "compass" + + check-php-compass-config-file: + exec: "php -i | grep compass.config_file" + exit-status: 0 + stdout: + contain-substring: "/etc/compass/config.yml" + +file: + /etc/compass/config.yml: + exists: true + owner: skpr + group: skpr + contents: + - "function_threshold" + - "suspend"