Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions fpm/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 && \
Expand All @@ -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"]
10 changes: 10 additions & 0 deletions fpm/compass/config.yml
Original file line number Diff line number Diff line change
@@ -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
15 changes: 15 additions & 0 deletions fpm/goss.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Loading