1
0
Fork 1
mirror of https://github.com/pixelfed/pixelfed.git synced 2024-12-22 07:42:41 +00:00

Merge pull request #5211 from intentionally-left-nil/fix-cache-perms

Docker fixes for composer install
This commit is contained in:
daniel 2024-11-08 21:50:12 -07:00 committed by GitHub
commit 710397322a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -257,17 +257,26 @@ COPY --link --from=composer-image /usr/bin/composer /usr/bin/composer
#! Changing user to runtime user #! Changing user to runtime user
USER ${RUNTIME_UID}:${RUNTIME_GID} USER ${RUNTIME_UID}:${RUNTIME_GID}
# Install composer dependencies # Install composer dependencies
# NOTE: we skip the autoloader generation here since we don't have all files avaliable (yet) # 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.json,target=/var/www/composer.json \
--mount=type=bind,source=composer.lock,target=/var/www/composer.lock \ --mount=type=bind,source=composer.lock,target=/var/www/composer.lock \
set -ex \ 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 all other files over
COPY --chown=${RUNTIME_UID}:${RUNTIME_GID} . /var/www/ 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 # Runtime: base
####################################################### #######################################################
@ -287,13 +296,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=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 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 USER root
# for detail why storage is copied this way, pls refer to https://github.com/pixelfed/pixelfed/pull/2137#discussion_r434468862 # for detail why storage is copied this way, pls refer to https://github.com/pixelfed/pixelfed/pull/2137#discussion_r434468862