From 37817adf61d64d75fa1fc373c28967c22668aa50 Mon Sep 17 00:00:00 2001 From: Ernesto Baschny Date: Tue, 4 Feb 2025 17:35:19 +0100 Subject: [PATCH 1/3] WIP PHP_DISABLE_EXTENSIONS functionality --- files/entrypoint-extras.sh | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/files/entrypoint-extras.sh b/files/entrypoint-extras.sh index 159a54e..c8ae3a0 100644 --- a/files/entrypoint-extras.sh +++ b/files/entrypoint-extras.sh @@ -10,10 +10,24 @@ if [ -z "${XDEBUG_MODE}" ] || [ "${XDEBUG_MODE}" = "off" ]; then # completely not load xdebug if its off rm -f /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini else - echo "* enabling XDEBUG: $XDEBUG_MODE" + echo "* Enabling XDEBUG: $XDEBUG_MODE" echo "zend_extension=xdebug.so" > /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini fi +# Enable all extensions which might have been disabled at some point first +if ls /usr/local/etc/php/conf.d/*php-ext*.disabled 1> /dev/null 2>&1; then + for file in /usr/local/etc/php/conf.d/*php-ext*.disabled; do + mv "$file" "${file%.disabled}" + done +fi +# Disable extensions based on PHP_DISABLE_EXTENSIONS +if [ ! -z "${PHP_DISABLE_EXTENSIONS}" ]; then + for ext in $(echo $PHP_DISABLE_EXTENSIONS | sed -e 's/,/ /g'); do + echo "* Disabling PHP extension: $ext" + mv /usr/local/etc/php/conf.d/docker-php-ext-$ext.ini /usr/local/etc/php/conf.d/docker-php-ext-$ext.ini.disabled + done +fi + if [ ! -z "${APPLICATION_UID}" ]; then echo "* Change uid of 'application' user to $APPLICATION_UID" usermod -u $APPLICATION_UID application From 6f65dfea4ce8973cc02cb860d0ee558914387a89 Mon Sep 17 00:00:00 2001 From: Ernesto Baschny Date: Fri, 7 Feb 2025 16:55:31 +0100 Subject: [PATCH 2/3] Warn if you try to disable an extension that does not exist --- files/entrypoint-extras.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/files/entrypoint-extras.sh b/files/entrypoint-extras.sh index c8ae3a0..da358ec 100644 --- a/files/entrypoint-extras.sh +++ b/files/entrypoint-extras.sh @@ -23,8 +23,12 @@ fi # Disable extensions based on PHP_DISABLE_EXTENSIONS if [ ! -z "${PHP_DISABLE_EXTENSIONS}" ]; then for ext in $(echo $PHP_DISABLE_EXTENSIONS | sed -e 's/,/ /g'); do - echo "* Disabling PHP extension: $ext" - mv /usr/local/etc/php/conf.d/docker-php-ext-$ext.ini /usr/local/etc/php/conf.d/docker-php-ext-$ext.ini.disabled + if [ -f "/usr/local/etc/php/conf.d/docker-php-ext-$ext.ini" ]; then + echo "* Disabling PHP extension: $ext" + mv /usr/local/etc/php/conf.d/docker-php-ext-$ext.ini /usr/local/etc/php/conf.d/docker-php-ext-$ext.ini.disabled + else + echo "* WARNING: PHP extension $ext not found, cannot disable" + fi done fi From 93036f0eefcaa711d5ec8b826b13163d9b7a258e Mon Sep 17 00:00:00 2001 From: Ernesto Baschny Date: Fri, 7 Feb 2025 16:55:45 +0100 Subject: [PATCH 3/3] Document the new DISABLE feature --- README.md | 1 + example-app/.env.example | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/README.md b/README.md index ccfbc8d..fa544bc 100644 --- a/README.md +++ b/README.md @@ -155,6 +155,7 @@ Application root is `/app`. Application runs as user `application` (uid=1000). | `ENV` | ssh | | The name of the environment to show on the shell prompt | | `PHP_INI_OVERRIDE` | fpm, ssh | | Allow overriding php.ini settings. Simply the multiline content for a php.ini here. Use "\n" for multiline i.e. in ECS | | `PHP_FPM_OVERRIDE` | fpm | | Allow overriding php-fpm pool settings. The multiline content for php-fpm.conf here. Use "\n" for multiline i.e. in ECS | +| `PHP_DISABLE_EXTENSIONS` | fpm, ssh | | Comma separated list of PHP extensions to disable. | ## Example usage diff --git a/example-app/.env.example b/example-app/.env.example index bb67e3d..9f42d0e 100644 --- a/example-app/.env.example +++ b/example-app/.env.example @@ -25,6 +25,10 @@ DB_NAME=typo3 # PHP settings overrides (examples) # ----------------------------------------- +# See full list here: +# https://github.com/cron-eu/docker-phpapp-php/blob/master/README.md#php-fpm-image-croneuphpapp-fpm +#PHP_DISABLE_EXTENSIONS=igbinary,redis + PHP_INI_OVERRIDE=" upload_max_filesize = 256M post_max_size = 256M