From 56fca34663ebd6838eb7929660f172db5fd818f9 Mon Sep 17 00:00:00 2001 From: Joao Gilberto Magalhaes Date: Wed, 21 Oct 2026 17:44:57 -0400 Subject: [PATCH 1/2] Install PHP extensions with PIE on 8.3+ and add php-disable-module - Replace pecl: with pie: in the 8.3-8.6 configs; 8.6 builds imagick, memcached and yaml from pinned commits with PIE - Ship pie and the pie-install helper in images with pie: in the config - Add php-disable-module (also --all-except and --list) to the images - Add PHP_DISABLE_MODULES and PHP_ENABLED_MODULES; deprecate DISABLEMODULE_ - install-sqlsvr: use PIE when available, skip the extension when it does not build, and detect aarch64 - Keep '#' inside words when stripping template comments --- assets/entrypoint.sh | 41 +++++--- assets/index.html | 21 +++- assets/script/install-sqlsvr.sh | 25 ++++- assets/script/php-disable-module.sh | 143 ++++++++++++++++++++++++++++ assets/script/pie-install.sh | 61 ++++++++++++ config/php-8.3.yml | 5 +- config/php-8.4.yml | 5 +- config/php-8.5.yml | 5 +- config/php-8.6.yml | 24 ++--- docs/building.md | 54 +++++++---- docs/dockerfile.md | 134 +++++++++++++++++--------- docs/environment.md | 34 ++++++- docs/security.md | 6 +- generator/__init__.py | 10 +- templates/php-base.j2 | 28 +++++- 15 files changed, 481 insertions(+), 115 deletions(-) create mode 100755 assets/script/php-disable-module.sh create mode 100755 assets/script/pie-install.sh diff --git a/assets/entrypoint.sh b/assets/entrypoint.sh index 5e49a2b..f27315f 100755 --- a/assets/entrypoint.sh +++ b/assets/entrypoint.sh @@ -28,22 +28,39 @@ then PHPMODULES=`php -i | grep "Scan this dir" | awk -F" => " '{print $2}'` PHPCUSTOM=/etc/php/conf.d - # Disable modules - for VAR in `printenv | grep DISABLEMODULE | grep -E '(true|yes|1)' | cut -d= -f1 | cut -d_ -f2- | awk '{print tolower($0)}'` - do - if [[ -f "$PHPMODULES/*$VAR.ini" ]] + # Keep only these modules (and the ones they require): PHP_ENABLED_MODULES="pdo_mysql,mbstring" + ENABLED_MODULES=`echo "$PHP_ENABLED_MODULES" | tr ',' ' '` + if [[ -n "${ENABLED_MODULES// /}" ]] + then + if ${VERBOSE_MODE} then - ${VERBOSE_MODE} && echo "Disabling Module $VAR ..." - rm "$PHPMODULES/*$VAR.ini" - elif [[ -f "$PHPMODULES/$VAR.ini" ]] + /usr/local/bin/php-disable-module --all-except $ENABLED_MODULES + else + /usr/local/bin/php-disable-module --all-except $ENABLED_MODULES > /dev/null + fi + fi + + # Disable modules: PHP_DISABLE_MODULES="yaml,memcached" (comma or space separated) + DISABLE_MODULES=`echo "$PHP_DISABLE_MODULES" | tr ',' ' '` + + # Deprecated: DISABLEMODULE_=true, will be removed in a future release + DEPRECATED_MODULES=`printenv | grep -E '^DISABLEMODULE_[^=]+=(true|yes|1)$' | cut -d= -f1 | cut -d_ -f2-` + if [[ -n "$DEPRECATED_MODULES" ]] + then + echo "DISABLEMODULE_ is deprecated, use PHP_DISABLE_MODULES=\"`echo $DEPRECATED_MODULES | tr '[:upper:] ' '[:lower:],'`\"" >&2 + DISABLE_MODULES="$DISABLE_MODULES $DEPRECATED_MODULES" + fi + + if [[ -n "${DISABLE_MODULES// /}" ]] + then + if ${VERBOSE_MODE} then - ${VERBOSE_MODE} && echo "Disabling Module $VAR ..." - rm "$PHPMODULES/$VAR.ini" + /usr/local/bin/php-disable-module $DISABLE_MODULES + echo else - ${VERBOSE_MODE} && echo "Module not found $VAR" + /usr/local/bin/php-disable-module $DISABLE_MODULES > /dev/null fi - done - ${VERBOSE_MODE} && echo + fi # List available modules if [[ "$VERBOSE" == "true" ]] diff --git a/assets/index.html b/assets/index.html index e74cad4..48cec0c 100644 --- a/assets/index.html +++ b/assets/index.html @@ -231,12 +231,27 @@

Environment Configurat
-
DISABLEMODULE_[name]
+
PHP_DISABLE_MODULES
-

Disable specific PHP modules at runtime to optimize performance.

+

Comma separated list of PHP modules to disable at runtime to optimize performance.

Default: All modules enabled

-
docker run -e DISABLEMODULE_DOM=true -e DISABLEMODULE_XSL=true @@DOCKER_IMAGE@@
+
docker run -e PHP_DISABLE_MODULES="dom,xsl" @@DOCKER_IMAGE@@
+ +
+
+
+ +
+
PHP_ENABLED_MODULES
+
+

Comma separated list of PHP modules to keep enabled at runtime; all the others are disabled. The modules they require are kept too.

+

Default: All modules enabled

+
+
docker run -e PHP_ENABLED_MODULES="pdo_mysql,mbstring" @@DOCKER_IMAGE@@