Fix apt cache not being properly utilized in Dockerfile (#28115)

This commit is contained in:
Michael Stanclift 2023-11-28 16:23:44 -06:00 committed by GitHub
parent 7a3b41eb54
commit c40cfc5d09
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 3 deletions

View file

@ -70,6 +70,8 @@ ARG TARGETPLATFORM
RUN echo "Target platform is $TARGETPLATFORM"
RUN \
# Remove automatic apt cache Docker cleanup scripts
rm -f /etc/apt/apt.conf.d/docker-clean; \
# Sets timezone
echo "${TZ}" > /etc/localtime; \
# Creates mastodon user/group and sets home directory
@ -127,7 +129,6 @@ RUN \
--mount=type=cache,id=apt-cache-${TARGETPLATFORM},target=/var/cache/apt,sharing=locked \
--mount=type=cache,id=apt-lib-${TARGETPLATFORM},target=/var/lib/apt,sharing=locked \
# Install build tools and bundler dependencies from APT
apt-get update; \
apt-get install -y --no-install-recommends \
g++ \
gcc \
@ -221,7 +222,6 @@ RUN \
--mount=type=cache,id=corepack-cache-${TARGETPLATFORM},target=/usr/local/share/.cache/corepack,sharing=locked \
--mount=type=cache,id=yarn-cache-${TARGETPLATFORM},target=/usr/local/share/.cache/yarn,sharing=locked \
# Apt update install non-dev versions of necessary components
apt-get update; \
apt-get install -y --no-install-recommends \
libssl3 \
libpq5 \

View file

@ -47,6 +47,8 @@ ARG TARGETPLATFORM
RUN echo "Target platform is ${TARGETPLATFORM}"
RUN \
# Remove automatic apt cache Docker cleanup scripts
rm -f /etc/apt/apt.conf.d/docker-clean; \
# Sets timezone
echo "${TZ}" > /etc/localtime; \
# Creates mastodon user/group and sets home directory
@ -60,7 +62,7 @@ RUN \
# Mount Apt cache and lib directories from Docker buildx caches
--mount=type=cache,id=apt-cache-${TARGETPLATFORM},target=/var/cache/apt,sharing=locked \
--mount=type=cache,id=apt-lib-${TARGETPLATFORM},target=/var/lib/apt,sharing=locked \
# upgrade to check for security updates to Debian image
# Upgrade to check for security updates to Debian image
apt-get update; \
apt-get dist-upgrade -yq; \
apt-get install -y --no-install-recommends \