diff --git a/Dockerfiles/prod/data/docker-entrypoint.sh b/Dockerfiles/prod/data/docker-entrypoint.sh index ce2b24e..11d964e 100755 --- a/Dockerfiles/prod/data/docker-entrypoint.sh +++ b/Dockerfiles/prod/data/docker-entrypoint.sh @@ -181,7 +181,8 @@ disable_modules "DISABLE_MODULES" "${DEBUG_LEVEL}" ### ### Run custom user supplied scripts ### -execute_custom_scripts "/startup.d" "${DEBUG_LEVEL}" +execute_custom_scripts "/startup.1.d" "${DEBUG_LEVEL}" +execute_custom_scripts "/startup.2.d" "${DEBUG_LEVEL}" ### diff --git a/Dockerfiles/work/data/docker-entrypoint.sh b/Dockerfiles/work/data/docker-entrypoint.sh index dd8b6bf..c7712f2 100755 --- a/Dockerfiles/work/data/docker-entrypoint.sh +++ b/Dockerfiles/work/data/docker-entrypoint.sh @@ -209,7 +209,8 @@ update_ca_certificates "/ca" "${DEBUG_LEVEL}" ### ### Run custom user supplied scripts ### -execute_custom_scripts "/startup.d" "${DEBUG_LEVEL}" +execute_custom_scripts "/startup.1.d" "${DEBUG_LEVEL}" +execute_custom_scripts "/startup.2.d" "${DEBUG_LEVEL}" ### diff --git a/README.md b/README.md index 26e4dcb..f184375 100644 --- a/README.md +++ b/README.md @@ -760,7 +760,7 @@ Have a look at the following table to see all offered volumes for each Docker im - prod

work + prod

work /etc/php-custom.d Mount this directory into your host computer and add custom \*.ini files in order to alter php behaviour. @@ -773,8 +773,12 @@ Have a look at the following table to see all offered volumes for each Docker im Mount this directory into your host computer and add custo \*.so files in order to add your php modules.

Note:Your should then also provide a custom \*.ini file in order to actually load your custom provided module. - /startup.d - Any executable scripts ending by \*.sh found in this directory will be executed during startup. This is useful to supply additional commands (such as installing custom software) when the container starts up. + /startup.1.d + Any executable scripts ending by \*.sh found in this directory will be executed during startup. This is useful to supply additional commands (such as installing custom software) when the container starts up. (will run before /startup.2.d) + + + /startup.2.d + Any executable scripts ending by \*.sh found in this directory will be executed during startup. This is useful to supply additional commands (such as installing custom software) when the container starts up. (will run after /startup.1.d) /var/log/php diff --git a/tests/prod/08-test-custom-user-scripts.sh b/tests/prod/08-test-custom-user-scripts-1.sh similarity index 98% rename from tests/prod/08-test-custom-user-scripts.sh rename to tests/prod/08-test-custom-user-scripts-1.sh index 63f7017..ccc064a 100755 --- a/tests/prod/08-test-custom-user-scripts.sh +++ b/tests/prod/08-test-custom-user-scripts-1.sh @@ -23,7 +23,7 @@ FLAVOUR="${3}" ### Check if PHP still starts up with working scripts ### RUN_SH_HOST="$( mktemp -d )" -RUN_SH_CONT="/startup.d" +RUN_SH_CONT="/startup.1.d" # Fix mount permissions chmod 0777 "${RUN_SH_HOST}" diff --git a/tests/prod/09-test-custom-user-scripts-2.sh b/tests/prod/09-test-custom-user-scripts-2.sh new file mode 100755 index 0000000..eadabd6 --- /dev/null +++ b/tests/prod/09-test-custom-user-scripts-2.sh @@ -0,0 +1,62 @@ +#!/usr/bin/env bash + +set -e +set -u +set -o pipefail + +CWD="$(cd -P -- "$(dirname -- "$0")" && pwd -P)" + +IMAGE="${1}" +VERSION="${2}" +FLAVOUR="${3}" + +# shellcheck disable=SC1090 +. "${CWD}/../.lib.sh" + + + +############################################################ +# Tests +############################################################ + +### +### Check if PHP still starts up with working scripts +### +RUN_SH_HOST="$( mktemp -d )" +RUN_SH_CONT="/startup.2.d" + +# Fix mount permissions +chmod 0777 "${RUN_SH_HOST}" + +# Add a startup script to execute +printf "#!/bin/bash\\necho 'abcdefghijklmnopq';\\n" > "${RUN_SH_HOST}/myscript1.sh" +chmod +x "${RUN_SH_HOST}/myscript1.sh" + +# Start PHP-FPM +did="$( docker_run "${IMAGE}:${VERSION}-${FLAVOUR}" "-e DEBUG_ENTRYPOINT=2 -e NEW_UID=$(id -u) -e NEW_GID=$(id -g) -v ${RUN_SH_HOST}:${RUN_SH_CONT}" )" + +# Wait for both containers to be up and running +run "sleep 10" + +# Check entrypoint for script run +if ! run "docker logs ${did} | grep 'myscript1.sh'"; then + docker_logs "${did}" || true + docker_stop "${did}" || true + rm -rf "${RUN_SH_HOST}" + echo "Failed" + exit 1 +fi + +# Check entrypoint for script output +if ! run "docker logs ${did} | grep 'abcdefghijklmnopq'"; then + docker_logs "${did}" || true + docker_stop "${did}" || true + rm -rf "${RUN_SH_HOST}" + echo "Failed" + exit 1 +fi + + +# Cleanup +docker_stop "${did}" +rm -rf "${RUN_SH_HOST}"