mirror of
https://github.com/librespeed/speedtest.git
synced 2026-07-02 06:43:29 +00:00
docker: drop runtime PHP scan-dir discovery for env var + apk path glob
The previous build-time discovery via PHP_CONFIG_FILE_SCAN_DIR worked but invoked a PHP binary just to learn a path that's already a stable contract of each base image: * php:8-apache exports PHP_INI_DIR=/usr/local/etc/php as part of the docker-library image template, stable across PHP majors. Reference it directly in the COPY destination — no RUN, no validation needed. * Alpine's apk php-apache2 always installs mod_php's conf.d at /etc/phpXX/conf.d (currently /etc/php84). The FROM php:8-alpine image also ships its own PHP at /usr/local/etc/php/conf.d, but mod_php doesn't read from there. Glob /etc/php*/conf.d to track the apk-installed PHP major automatically; explicit error if the glob matches nothing. Net effect: Debian goes from a 5-line RUN block to a 1-line COPY. Alpine keeps a small RUN block but no longer invokes a PHP binary, so it doesn't matter which of the two PHP installs `php` resolves to via $PATH. Verified: both variants build, install the override at the right conf.d, mod_php reports post_max_size=32M, and a 20 MB POST to /backend/empty.php returns HTTP 200 / 0 bytes with no warnings. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
3b3cddeb41
commit
db4a5f8d5a
2 changed files with 19 additions and 9 deletions
|
|
@ -10,11 +10,10 @@ RUN install-php-extensions iconv gd pdo pdo_mysql pdo_pgsql pgsql \
|
|||
&& apt-get clean \
|
||||
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
|
||||
|
||||
COPY docker/librespeed-php.ini /tmp/librespeed-php.ini
|
||||
RUN scan_dir="$(php -r 'echo rtrim(PHP_CONFIG_FILE_SCAN_DIR);')" \
|
||||
&& [ -n "$scan_dir" ] \
|
||||
&& install -D -m 0644 /tmp/librespeed-php.ini "$scan_dir/99-librespeed.ini" \
|
||||
&& rm /tmp/librespeed-php.ini
|
||||
# PHP_INI_DIR is set by the official php:8-apache image to /usr/local/etc/php
|
||||
# and has been stable across PHP majors. Using the env var documents intent
|
||||
# and follows any future upstream change to the path automatically.
|
||||
COPY docker/librespeed-php.ini ${PHP_INI_DIR}/conf.d/99-librespeed.ini
|
||||
|
||||
# Prepare files and folders
|
||||
RUN mkdir -p /speedtest/
|
||||
|
|
|
|||
|
|
@ -20,11 +20,22 @@ RUN apk add --quiet --no-cache \
|
|||
RUN ln -sf /dev/stdout /var/log/apache2/access.log && \
|
||||
ln -sf /dev/stderr /var/log/apache2/error.log
|
||||
|
||||
# This image has two PHP installs: the FROM php:8-alpine binary (conf.d at
|
||||
# /usr/local/etc/php/conf.d) and the apk-installed php-apache2 (conf.d at
|
||||
# /etc/phpXX/conf.d). mod_php uses the apk one — glob /etc/php*/conf.d to
|
||||
# find it without pinning the PHP major.
|
||||
COPY docker/librespeed-php.ini /tmp/librespeed-php.ini
|
||||
RUN scan_dir="$(/usr/bin/php -r 'echo rtrim(PHP_CONFIG_FILE_SCAN_DIR);')" \
|
||||
&& [ -n "$scan_dir" ] \
|
||||
&& install -D -m 0644 /tmp/librespeed-php.ini "$scan_dir/99-librespeed.ini" \
|
||||
&& rm /tmp/librespeed-php.ini
|
||||
RUN set -eu; \
|
||||
scan_dir=""; \
|
||||
for d in /etc/php*/conf.d; do \
|
||||
[ -d "$d" ] && scan_dir="$d" && break; \
|
||||
done; \
|
||||
if [ -z "$scan_dir" ]; then \
|
||||
echo "ERROR: no /etc/php*/conf.d directory found; apk php-apache2 install layout may have changed" >&2; \
|
||||
exit 1; \
|
||||
fi; \
|
||||
install -D -m 0644 /tmp/librespeed-php.ini "$scan_dir/99-librespeed.ini"; \
|
||||
rm /tmp/librespeed-php.ini
|
||||
|
||||
# Prepare files and folders
|
||||
RUN mkdir -p /speedtest/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue