EXPERIMENT: drop FROM php:8-alpine in favor of FROM alpine:3.21

The current Dockerfile.alpine pulls FROM php:8-alpine and then `apk
add php-apache2`. The result is two PHP installs side by side: the
docker-library PHP at /usr/local/bin/php (~30 MB, never used by
Apache) and the apk-installed PHP at /usr/bin/php (which mod_php
actually loads).

Pinning a fresh Alpine release and installing the apk packages
directly drops the dead /usr/local/bin/php install entirely.
Expected wins:
- Smaller image (~30 MB less; 2024 baseline was ~120 MB)
- One PHP binary, no $PATH ambiguity
- Cleaner story for any follow-up that touches PHP config
This commit is contained in:
Akira Yamamoto 2026-04-27 09:46:22 +10:00
parent 853214db6c
commit 475cae5b0e

View file

@ -1,7 +1,8 @@
FROM php:8-alpine
FROM alpine:3.23
RUN apk add --quiet --no-cache \
bash \
apache2 \
php \
php-apache2 \
php-ctype \
php-phar \
@ -15,12 +16,6 @@ RUN apk add --quiet --no-cache \
php-session \
php-sqlite3
# # use docker-php-extension-installer for automatically get the right packages installed
# ADD --chmod=0755 https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/
# # Install extensions
# RUN install-php-extensions iconv gd pdo pdo_mysql pdo_pgsql pgsql
RUN ln -sf /dev/stdout /var/log/apache2/access.log && \
ln -sf /dev/stderr /var/log/apache2/error.log