diff --git a/8/Dockerfile b/8/Dockerfile index c57f67e2..2a8aab91 100644 --- a/8/Dockerfile +++ b/8/Dockerfile @@ -457,6 +457,7 @@ EXPOSE 9000 COPY templates /etc/gotpl/ COPY docker-entrypoint.sh / COPY bin /usr/local/bin/ +COPY init /docker-entrypoint-init.d/ ENTRYPOINT ["/docker-entrypoint.sh"] CMD ["sudo", "-E", "php-fpm"] diff --git a/8/init/90_wodby_init.sh b/8/init/90_wodby_init.sh new file mode 100755 index 00000000..85542171 --- /dev/null +++ b/8/init/90_wodby_init.sh @@ -0,0 +1,26 @@ +#!/usr/bin/env bash + +set -e + +if [[ -n "${DEBUG}" ]]; then + set -x +fi + +# Applies the service init action on container start. +# +# The init action prepares the application codebase for this image, for example +# by wiring the generated Wodby config into the application's own settings file +# and symlinking public files to the persistent volume. Its steps are guarded +# and idempotent, so when the image was built with the init action already +# applied this is a no-op. +# +# WODBY_INIT_ACTION names a target in /usr/local/bin/actions.mk and is provided +# as an environment variable rather than baked into the image, so the init +# action is applied no matter which Dockerfile produced the image. +# +# This file is sourced by exec_init_scripts, not executed in a subshell. Do not +# use "exit" here, it would terminate the entrypoint and stop the container. +if [[ -n "${WODBY_INIT_ACTION}" ]]; then + echo "Applying init action: ${WODBY_INIT_ACTION}" + make "${WODBY_INIT_ACTION}" -f /usr/local/bin/actions.mk +fi