Configure mainland build mirrors and persist BuildKit apt and pip caches

This commit is contained in:
Pigway
2026-10-07 17:37:33 +08:00
parent 1e13977ec2
commit d88c88f876
8 changed files with 83 additions and 8 deletions
+13 -6
View File
@@ -1,12 +1,19 @@
ARG PYTHON_BASE=python:3.14.5-slim-bookworm@sha256:ec58d916f9e24a6035cab2bdf07f6206c4cc092a16613c60597534711332d9d6
FROM ${PYTHON_BASE}
ARG DEBIAN_MIRROR=deb.debian.org
ARG DEBIAN_SECURITY_MIRROR=deb.debian.org
ARG TARGETARCH
ENV PYTHONDONTWRITEBYTECODE=1 PYTHONUNBUFFERED=1 TZ=Asia/Shanghai \
DATA_DIR=/data CONFIG_DIR=/config
WORKDIR /app
# CJK fonts intentionally retained for readable Chinese rendering.
RUN --mount=type=bind,source=build-cache/debs,target=/build-debs,readonly sed -i "s|http://deb.debian.org|https://${DEBIAN_MIRROR}|g" /etc/apt/sources.list.d/debian.sources \
&& apt-get update \
RUN --mount=type=cache,id=frameflow-bookworm-apt-${TARGETARCH},target=/var/cache/apt,sharing=locked \
--mount=type=cache,id=frameflow-bookworm-lists-${TARGETARCH},target=/var/lib/apt/lists,sharing=locked \
--mount=type=bind,source=build-cache/debs,target=/build-debs,readonly \
rm -f /etc/apt/apt.conf.d/docker-clean \
&& printf 'Binary::apt::APT::Keep-Downloaded-Packages "true";\n' > /etc/apt/apt.conf.d/keep-cache \
&& sed -i "s|http://deb.debian.org/debian-security|https://${DEBIAN_SECURITY_MIRROR}/debian-security|g; s|http://deb.debian.org/debian|https://${DEBIAN_MIRROR}/debian|g" /etc/apt/sources.list.d/debian.sources \
&& apt-get -o Acquire::Retries=3 -o Acquire::https::Timeout=60 update \
&& if [ -f /build-debs/fonts-noto-cjk.deb ]; then \
font_version=$(apt-cache policy fonts-noto-cjk | awk '$1=="Candidate:" {print $2}'); \
font_sha=$(apt-cache show "fonts-noto-cjk=$font_version" | awk '$1=="SHA256:" {print $2;exit}'); \
@@ -15,16 +22,16 @@ RUN --mount=type=bind,source=build-cache/debs,target=/build-debs,readonly sed -i
apt-get install -y --no-install-recommends tzdata; \
dpkg -i /build-debs/fonts-noto-cjk.deb; \
else apt-get install -y --no-install-recommends fonts-noto-cjk tzdata; fi \
&& rm -rf /var/lib/apt/lists/* \
&& groupadd --gid 10333 frameflow && useradd --uid 10333 --gid 10333 --no-create-home frameflow \
&& mkdir -p /data/images /data/generated /data/cache /config \
&& chown -R 10333:10333 /data /config
COPY requirements.lock ./
RUN --mount=type=bind,source=build-cache/wheels,target=/build-wheels,readonly \
RUN --mount=type=cache,id=frameflow-pip-py314-${TARGETARCH},target=/root/.cache/pip,sharing=locked \
--mount=type=bind,source=build-cache/wheels,target=/build-wheels,readonly \
if [ -f /build-wheels/SHA256SUMS ]; then \
(cd /build-wheels && sha256sum -c SHA256SUMS) \
&& pip install --no-cache-dir --no-index --find-links=/build-wheels -r requirements.lock; \
else pip install --no-cache-dir -r requirements.lock; fi
&& pip install --no-index --find-links=/build-wheels -r requirements.lock; \
else pip install -r requirements.lock; fi
COPY pigway_frame_flow ./pigway_frame_flow
COPY vendor ./vendor
ARG BUILD_COMMIT=development