From 685f62a5d0550f4a64e89a2dac60dbae0c5d2586 Mon Sep 17 00:00:00 2001 From: Christian Winther Date: Mon, 15 Jan 2024 18:44:43 +0000 Subject: [PATCH] allow skipping one-time setup tasks --- Dockerfile | 4 +- .../docker/entrypoint.d/04-defaults.envsh | 3 ++ .../root/docker/install/php-extensions.sh | 48 ++++++------------- 3 files changed, 20 insertions(+), 35 deletions(-) diff --git a/Dockerfile b/Dockerfile index 33d0eeee3..6151d8758 100644 --- a/Dockerfile +++ b/Dockerfile @@ -40,8 +40,8 @@ ARG RUNTIME_GID=33 # often called 'www-data' ARG APT_PACKAGES_EXTRA="" # Extensions installed via [pecl install] -ARG PHP_PECL_EXTENSIONS="" -ARG PHP_PECL_EXTENSIONS_EXTRA="" +ARG PHP_PECL_EXTENSIONS= +ARG PHP_PECL_EXTENSIONS_EXTRA= # Extensions installed via [docker-php-ext-install] ARG PHP_EXTENSIONS="intl bcmath zip pcntl exif curl gd" diff --git a/docker/shared/root/docker/entrypoint.d/04-defaults.envsh b/docker/shared/root/docker/entrypoint.d/04-defaults.envsh index 352ea23b7..d47f55728 100755 --- a/docker/shared/root/docker/entrypoint.d/04-defaults.envsh +++ b/docker/shared/root/docker/entrypoint.d/04-defaults.envsh @@ -10,6 +10,9 @@ entrypoint-set-script-name "${BASH_SOURCE[0]}" +: "${MAX_PHOTO_SIZE:-}" +: "${MAX_ALBUM_LENGTH:-}" + load-config-files # We assign a 1MB buffer to the just-in-time calculated max post size to allow for fields and overhead diff --git a/docker/shared/root/docker/install/php-extensions.sh b/docker/shared/root/docker/install/php-extensions.sh index 8abb3dff8..42c149d76 100755 --- a/docker/shared/root/docker/install/php-extensions.sh +++ b/docker/shared/root/docker/install/php-extensions.sh @@ -1,20 +1,14 @@ #!/bin/bash set -ex -o errexit -o nounset -o pipefail -# shellcheck disable=SC2223 -: ${PHP_PECL_EXTENSIONS:=""} +declare -a pecl_extensions=() +readarray -d ' ' -t pecl_extensions < <(echo -n "${PHP_PECL_EXTENSIONS:-}") +readarray -d ' ' -t -O "${#pecl_extensions[@]}" pecl_extensions < <(echo -n "${PHP_PECL_EXTENSIONS_EXTRA:-}") -# shellcheck disable=SC2223 -: ${PHP_PECL_EXTENSIONS_EXTRA:=""} - -# shellcheck disable=SC2223 -: ${PHP_EXTENSIONS:=""} - -# shellcheck disable=SC2223 -: ${PHP_EXTENSIONS_EXTRA:=""} - -# shellcheck disable=SC2223 -: ${PHP_EXTENSIONS_DATABASE:=""} +declare -a php_extensions=() +readarray -d ' ' -t php_extensions < <(echo -n "${PHP_EXTENSIONS:-}") +readarray -d ' ' -t -O "${#php_extensions[@]}" php_extensions < <(echo -n "${PHP_EXTENSIONS_EXTRA:-}") +readarray -d ' ' -t -O "${#php_extensions[@]}" php_extensions < <(echo -n "${PHP_EXTENSIONS_DATABASE:-}") # Grab the PHP source code so we can compile against it docker-php-source extract @@ -28,33 +22,21 @@ docker-php-ext-configure gd \ # Optional script folks can copy into their image to do any [docker-php-ext-configure] work before the [docker-php-ext-install] # this can also overwirte the [gd] configure above by simply running it again -if [[ -f /install/php-extension-configure.sh ]]; then - if [ ! -x "/install/php-extension-configure.sh" ]; then - echo >&2 "ERROR: found /install/php-extension-configure.sh but its not executable - please [chmod +x] the file!" +declare -r custom_pre_configure_script="" +if [[ -e "${custom_pre_configure_script}" ]]; then + if [ ! -x "${custom_pre_configure_script}" ]; then + echo >&2 "ERROR: found ${custom_pre_configure_script} but its not executable - please [chmod +x] the file!" exit 1 fi - /install/php-extension-configure.sh + "${custom_pre_configure_script}" fi # Install pecl extensions -pecl install "${PHP_PECL_EXTENSIONS}" "${PHP_PECL_EXTENSIONS_EXTRA}" +pecl install "${pecl_extensions[@]}" # PHP extensions (dependencies) -# -# shellcheck disable=SC2086 -docker-php-ext-install \ - -j "$(nproc)" \ - ${PHP_EXTENSIONS} \ - ${PHP_EXTENSIONS_EXTRA} \ - ${PHP_EXTENSIONS_DATABASE} +docker-php-ext-install -j "$(nproc)" "${php_extensions[@]}" # Enable all extensions -# -# shellcheck disable=SC2086 -docker-php-ext-enable \ - ${PHP_PECL_EXTENSIONS} \ - ${PHP_PECL_EXTENSIONS_EXTRA} \ - ${PHP_EXTENSIONS} \ - ${PHP_EXTENSIONS_EXTRA} \ - ${PHP_EXTENSIONS_DATABASE} +docker-php-ext-enable "${pecl_extensions[@]}" "${php_extensions[@]}"