From 757008566cc313cde939db9149855b01737b7ab2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cau=C3=AA=20Faleiros?= Date: Thu, 29 Oct 2026 14:57:58 -0300 Subject: [PATCH] fix: image builds refresh OS packages once a day, so a cached layer cannot hide a new fix Run 219 was blocked by CVE-2026-111497 in brotli-libs 1.2.0: the fix (1.2.1) was out, but the cached apk upgrade layer was reused. The build day is now part of that layer in both images. Co-Authored-By: Claude Opus 5.5 --- .gitea/workflows/deploy.yml | 4 ++-- deploy/Dockerfile.api | 5 ++++- deploy/Dockerfile.web | 8 ++++++-- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml index bcda13b..8cc5ef4 100644 --- a/.gitea/workflows/deploy.yml +++ b/.gitea/workflows/deploy.yml @@ -189,7 +189,7 @@ jobs: set -- [ -n "$PYTHON_BASE_IMAGE" ] && set -- --build-arg PYTHON_BASE_IMAGE="$PYTHON_BASE_IMAGE" docker build --file deploy/Dockerfile.api "$@" \ - --build-arg VCS_REF="${{ gitea.sha }}" \ + --build-arg VCS_REF="${{ gitea.sha }}" --build-arg PACKAGES_DAY="$(date -u +%F)" \ --tag "$image:latest" --tag "$image:${{ gitea.sha }}" . - name: Build web run: | @@ -198,7 +198,7 @@ jobs: [ -n "$PYTHON_BASE_IMAGE" ] && set -- --build-arg PYTHON_BASE_IMAGE="$PYTHON_BASE_IMAGE" [ -n "$NGINX_BASE_IMAGE" ] && set -- "$@" --build-arg NGINX_BASE_IMAGE="$NGINX_BASE_IMAGE" docker build --file deploy/Dockerfile.web "$@" \ - --build-arg VCS_REF="${{ gitea.sha }}" \ + --build-arg VCS_REF="${{ gitea.sha }}" --build-arg PACKAGES_DAY="$(date -u +%F)" \ --tag "$image:latest" --tag "$image:${{ gitea.sha }}" . # CRITICAL blocks, HIGH is reported. Both images carry zero CRITICAL after # the base pinning and OS upgrades, so this gate holds the line already diff --git a/deploy/Dockerfile.api b/deploy/Dockerfile.api index 074dc7c..591d62d 100644 --- a/deploy/Dockerfile.api +++ b/deploy/Dockerfile.api @@ -15,7 +15,10 @@ LABEL org.opencontainers.image.title="DTF Portal/API" \ # is what the production image was doing while the local one already did this. # pg_dump and age are for the database backup (ops/db_backup.py). Debian 13 # ships PostgreSQL 17, the server's major version, which pg_dump must match. -RUN apt-get update \ +# The day (PACKAGES_DAY, set by CI) is part of this layer, so a cached build +# still fetches the fixes published since. +ARG PACKAGES_DAY=unset +RUN echo "packages refreshed: $PACKAGES_DAY" && apt-get update \ && apt-get upgrade -y \ && apt-get install -y --no-install-recommends postgresql-client-17 age \ && rm -rf /var/lib/apt/lists/* diff --git a/deploy/Dockerfile.web b/deploy/Dockerfile.web index 733464a..491d819 100644 --- a/deploy/Dockerfile.web +++ b/deploy/Dockerfile.web @@ -14,8 +14,12 @@ ENV NGINX_TEMPLATE=/build/deploy/nginx.conf.template RUN python infra/compile_web.py FROM ${NGINX_BASE_IMAGE} -# Same reason as the API image: a pinned base freezes its packages. -RUN apk upgrade --no-cache +# Same reason as the API image: a pinned base freezes its packages. The day +# (PACKAGES_DAY, set by CI) is part of this layer, so a cached build still +# fetches the fixes published since: brotli-libs 1.2.1 on 2026-10-29 was +# missed by a cached upgrade layer and blocked the release gate. +ARG PACKAGES_DAY=unset +RUN echo "packages refreshed: $PACKAGES_DAY" && apk upgrade --no-cache ARG VCS_REF=unknown LABEL org.opencontainers.image.title="DTF Site and Kanban" \ org.opencontainers.image.revision="$VCS_REF" \