diff --git a/apache/Dockerfile b/apache/Dockerfile index ee965f7..6990875 100644 --- a/apache/Dockerfile +++ b/apache/Dockerfile @@ -116,6 +116,11 @@ COPY ./supervisor.d/ /etc/supervisor/conf.d/ #ENTRYPOINTS COPY --chmod=755 ./entrypoint.d/ /etc/entrypoint.d/ +COPY --chmod=755 ./entrypoint-runner.sh /usr/local/bin/entrypoint-runner.sh + +# Persistent .env storage (see entrypoint.d/20-env.sh) +RUN mkdir -p /config +VOLUME /config # Install composer # bun RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer @@ -124,7 +129,7 @@ RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local RUN sed -ri -e 's!/var/www/html!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/sites-available/*.conf && \ sed -ri -e 's!/var/www/!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/apache2.conf /etc/apache2/conf-available/*.conf && \ sed -i 's/^exec /printenv > \/etc\/environment\n\nexec /' /usr/local/bin/apache2-foreground && \ - sed -i 's#^exec #for f in /etc/entrypoint.d/*.sh; do if [ -x "$f" ]; then "$f" || { echo "entrypoint script failed: $f" >\&2; exit 1; }; fi; done\n\nexec #' /usr/local/bin/apache2-foreground + sed -i 's#^exec #entrypoint-runner.sh\n\nexec #' /usr/local/bin/apache2-foreground #Cleaning RUN apt-get clean && \ diff --git a/apache/entrypoint-runner.sh b/apache/entrypoint-runner.sh new file mode 100644 index 0000000..da50d06 --- /dev/null +++ b/apache/entrypoint-runner.sh @@ -0,0 +1,9 @@ +#!/bin/sh +# Legacy images ship their own start.sh in the app root and do the whole setup themselves. +[ -f "${APP_ROOT:-/var/www/html}/start.sh" ] && exit 0 + +for f in /etc/entrypoint.d/*.sh; do + if [ -x "$f" ]; then + "$f" || { echo "entrypoint script failed: $f" >&2; exit 1; } + fi +done diff --git a/apache/entrypoint.d/05-permissions.sh b/apache/entrypoint.d/05-permissions.sh new file mode 100644 index 0000000..9e9c34f --- /dev/null +++ b/apache/entrypoint.d/05-permissions.sh @@ -0,0 +1,10 @@ +#!/bin/sh +# Mounted volumes are usually root-owned, so www-data could not write into storage and bootstrap/cache. +cd "${APP_ROOT:-/var/www/html}" || exit 0 + +for dir in storage bootstrap/cache; do + if [ -d "$dir" ] && [ "$(stat -c %U "$dir")" != "www-data" ]; then + chown -R www-data:www-data "$dir" + fi +done +exit 0 diff --git a/fmp-alpine/Dockerfile b/fmp-alpine/Dockerfile index c7ff9d2..4b7c15a 100644 --- a/fmp-alpine/Dockerfile +++ b/fmp-alpine/Dockerfile @@ -111,6 +111,11 @@ COPY ./supervisor.d/ /etc/supervisor/conf.d/ # Entrypoint scripts (run in order from the stock entrypoint) COPY --chmod=755 ./entrypoint.d/ /etc/entrypoint.d/ -RUN sed -i 's#^exec #for f in /etc/entrypoint.d/*.sh; do if [ -x "$f" ]; then "$f" || { echo "entrypoint script failed: $f" >\&2; exit 1; }; fi; done\n\nexec #' /usr/local/bin/docker-php-entrypoint +COPY --chmod=755 ./entrypoint-runner.sh /usr/local/bin/entrypoint-runner.sh + +# Persistent .env storage (see entrypoint.d/20-env.sh) +RUN mkdir -p /config +VOLUME /config +RUN sed -i 's#^exec #entrypoint-runner.sh\n\nexec #' /usr/local/bin/docker-php-entrypoint WORKDIR ${APP_ROOT} diff --git a/fmp-alpine/entrypoint-runner.sh b/fmp-alpine/entrypoint-runner.sh new file mode 100644 index 0000000..da50d06 --- /dev/null +++ b/fmp-alpine/entrypoint-runner.sh @@ -0,0 +1,9 @@ +#!/bin/sh +# Legacy images ship their own start.sh in the app root and do the whole setup themselves. +[ -f "${APP_ROOT:-/var/www/html}/start.sh" ] && exit 0 + +for f in /etc/entrypoint.d/*.sh; do + if [ -x "$f" ]; then + "$f" || { echo "entrypoint script failed: $f" >&2; exit 1; } + fi +done diff --git a/fmp-alpine/entrypoint.d/05-permissions.sh b/fmp-alpine/entrypoint.d/05-permissions.sh new file mode 100644 index 0000000..9e9c34f --- /dev/null +++ b/fmp-alpine/entrypoint.d/05-permissions.sh @@ -0,0 +1,10 @@ +#!/bin/sh +# Mounted volumes are usually root-owned, so www-data could not write into storage and bootstrap/cache. +cd "${APP_ROOT:-/var/www/html}" || exit 0 + +for dir in storage bootstrap/cache; do + if [ -d "$dir" ] && [ "$(stat -c %U "$dir")" != "www-data" ]; then + chown -R www-data:www-data "$dir" + fi +done +exit 0