mirror of
https://github.com/Studio-Saelix/sencho.git
synced 2026-08-21 07:36:40 +00:00
ci: daily cache-bust the Alpine apk upgrade layer (#491)
The runtime stage's `apk upgrade --no-cache` layer was being reused from the buildx gha/registry cache indefinitely, so newly-patched Alpine packages (e.g. openssl CVE fixes) could sit behind a stale layer until an unrelated Dockerfile change invalidated it by coincidence. This surfaced as Trivy hard-failing on CVE-2026-28390 (libcrypto3/libssl3 DoS in CMS) on the github-app-token-migration PR, even though upstream Alpine had already published 3.5.6-r0 with the fix. Add an APK_CACHE_BUST build-arg that CI sets to the current UTC date (YYYY-MM-DD). Each calendar day the arg value changes, which changes the RUN layer's hash, which forces buildx to re-execute `apk upgrade` and pick up whatever Alpine has published that day. All three build invocations (PR docker-validate, release pre-publish scan, release multi-arch push) pass the same value, so the scan and the published artifact always share a layer and Trivy never scans stale bits. Default value `unset` lets local developers `docker build` without the arg; production CI always supplies the date.
This commit is contained in:
@@ -131,6 +131,14 @@ jobs:
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v4
|
||||
|
||||
# Computed once per job run. Feeds Dockerfile's APK_CACHE_BUST arg so
|
||||
# the `apk upgrade` layer rebuilds at least once per calendar day, even
|
||||
# when every other input to the layer is cached. See Dockerfile:115-122
|
||||
# for the rationale.
|
||||
- name: Compute daily apk cache bust value
|
||||
id: apk-bust
|
||||
run: echo "date=$(date -u +%Y-%m-%d)" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Build Docker image (validation only)
|
||||
uses: docker/build-push-action@v7
|
||||
with:
|
||||
@@ -140,6 +148,8 @@ jobs:
|
||||
tags: sencho:pr-test
|
||||
cache-from: type=gha
|
||||
cache-to: type=gha,mode=max
|
||||
build-args: |
|
||||
APK_CACHE_BUST=${{ steps.apk-bust.outputs.date }}
|
||||
|
||||
- name: Scan image for vulnerabilities (Trivy)
|
||||
# Hard-fails the PR on any HIGH or CRITICAL finding that is not listed
|
||||
|
||||
Reference in New Issue
Block a user