From 0e8ea578d97e6e7c0a604c56ff4f08a72699dca5 Mon Sep 17 00:00:00 2001 From: Anil Kulkarni Date: Sun, 7 Jul 2024 00:11:50 -0700 Subject: [PATCH] Fix composer install step First, fix the permissions of /cache/composer to be writeable by www-data Next, skip the post-install scripts since the repo isn't ready yet Then, run the autoload generator, and finally do the post-install steps --- Dockerfile | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/Dockerfile b/Dockerfile index ff8c9e24b..45e4bda54 100644 --- a/Dockerfile +++ b/Dockerfile @@ -256,17 +256,26 @@ COPY --link --from=composer-image /usr/bin/composer /usr/bin/composer #! Changing user to runtime user USER ${RUNTIME_UID}:${RUNTIME_GID} + # Install composer dependencies # NOTE: we skip the autoloader generation here since we don't have all files avaliable (yet) -RUN --mount=type=cache,id=pixelfed-composer-${PHP_VERSION},sharing=locked,target=/cache/composer \ +RUN --mount=type=cache,id=pixelfed-composer-${PHP_VERSION},sharing=locked,uid=${RUNTIME_UID},gid=${RUNTIME_GID},target=/cache/composer \ --mount=type=bind,source=composer.json,target=/var/www/composer.json \ --mount=type=bind,source=composer.lock,target=/var/www/composer.lock \ set -ex \ - && composer install --prefer-dist --no-autoloader --ignore-platform-reqs + && composer install --prefer-dist --no-autoloader --ignore-platform-reqs --no-scripts # Copy all other files over COPY --chown=${RUNTIME_UID}:${RUNTIME_GID} . /var/www/ +# Generate optimized autoloader now that we have all files around +RUN set -ex \ + && ENABLE_CONFIG_CACHE=false composer dump-autoload --optimize + +# Now we can run the post-install scripts +RUN set -ex \ + && composer run-script post-update-cmd + ####################################################### # Runtime: base ####################################################### @@ -286,13 +295,6 @@ COPY --link --from=composer-image /usr/bin/composer /usr/bin/composer COPY --link --from=composer-and-src --chown=${RUNTIME_UID}:${RUNTIME_GID} /var/www /var/www COPY --link --from=frontend-build --chown=${RUNTIME_UID}:${RUNTIME_GID} /var/www/public /var/www/public -#! Changing user to runtime user -USER ${RUNTIME_UID}:${RUNTIME_GID} - -# Generate optimized autoloader now that we have all files around -RUN set -ex \ - && ENABLE_CONFIG_CACHE=false composer dump-autoload --optimize - USER root # for detail why storage is copied this way, pls refer to https://github.com/pixelfed/pixelfed/pull/2137#discussion_r434468862