Skip to content

Commit 00ebc85

Browse files
authored
Merge pull request #5 from RoopsyDaisy/claude/a4-buildx-cache
A4: opt-in buildx GHA layer cache for CI builds
2 parents ea80701 + 2aee2c0 commit 00ebc85

2 files changed

Lines changed: 33 additions & 8 deletions

File tree

.github/workflows/ci.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,15 @@ jobs:
3737
- uses: actions/checkout@v4
3838
with:
3939
submodules: recursive # vendor/fvs (+NVEL), fvs-build, fvs-interface
40+
# buildx + the GHA cache backend (CACHE=gha) so unchanged layers (the FVS
41+
# compile, renv restore) are reused across PR/branch runs. publish.yaml
42+
# deliberately omits this -- release builds miss the cache for
43+
# reproducibility (docs/UPSTREAM_REVIEW.md A4).
44+
- uses: docker/setup-buildx-action@v3
4045
- name: Build + smoke test
4146
run: bash scripts/build_images.sh
4247
env:
4348
ENGINE: docker
4449
FVS_VARIANT: ie
4550
FVS_BASE: source
51+
CACHE: gha

scripts/build_images.sh

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,35 @@ img_for() {
5151
esac
5252
}
5353

54+
# Layer caching (opt-in via CACHE; default off so local/podman builds are
55+
# unchanged). CACHE=gha uses buildx + the GitHub Actions cache backend, which is
56+
# why ci.yaml sets it but publish.yaml does NOT -- release builds intentionally
57+
# miss the cache for reproducibility (see docs/UPSTREAM_REVIEW.md A4). Cache is
58+
# scoped per target so webgui and cluster don't evict each other. buildx needs
59+
# --load to put the image in the local store for the smoke/test `docker run`.
60+
CACHE="${CACHE:-}"
61+
5462
for t in $TARGETS; do
5563
tag="$(img_for "$t")"
56-
echo ">>> build target=$t -> $tag (FVS_VARIANT=$FVS_VARIANT FVS_BASE=$FVS_BASE)"
57-
"$ENGINE" build -f docker/Dockerfile --target "$t" \
58-
--build-arg "FVS_VARIANT=${FVS_VARIANT}" \
59-
--build-arg "FVS_BASE=${FVS_BASE}" \
60-
--build-arg "VCS_REF=${VCS_REF}" \
61-
--build-arg "FVS_SOURCE_REF=${FVS_SOURCE_REF}" \
62-
--build-arg "BUILD_DATE=${BUILD_DATE}" \
63-
-t "$tag" .
64+
echo ">>> build target=$t -> $tag (FVS_VARIANT=$FVS_VARIANT FVS_BASE=$FVS_BASE CACHE=${CACHE:-off})"
65+
common_args=(
66+
-f docker/Dockerfile --target "$t"
67+
--build-arg "FVS_VARIANT=${FVS_VARIANT}"
68+
--build-arg "FVS_BASE=${FVS_BASE}"
69+
--build-arg "VCS_REF=${VCS_REF}"
70+
--build-arg "FVS_SOURCE_REF=${FVS_SOURCE_REF}"
71+
--build-arg "BUILD_DATE=${BUILD_DATE}"
72+
-t "$tag"
73+
)
74+
if [ "$CACHE" = "gha" ]; then
75+
scope="${FVS_VARIANT}-${FVS_BASE}-${t}"
76+
"$ENGINE" buildx build "${common_args[@]}" \
77+
--cache-from "type=gha,scope=${scope}" \
78+
--cache-to "type=gha,mode=max,scope=${scope}" \
79+
--load .
80+
else
81+
"$ENGINE" build "${common_args[@]}" .
82+
fi
6483
done
6584

6685
# Smoke test inside each built image. smoke_test.R is baked into the image (at

0 commit comments

Comments
 (0)