fix(deploy): keep BuildKit cache and use Huawei mirrors for API images
Gitea run 2828 validated, then publish hit the 60-minute deadline while Aliyun apt/pip crawled at about 22 kB/s after a 72h cache prune on a runner with 677 GiB free. Skip BuildKit prune when disk is above the minimum, split API apt/pip layers, and point apt/pypi at Huawei Cloud.
This commit is contained in:
@@ -66,20 +66,26 @@ if [ -n "$STALE_IMAGES" ]; then
|
||||
printf '%s\n' "$STALE_IMAGES" | xargs -r docker image rm || true
|
||||
fi
|
||||
|
||||
# BuildKit layer cache is what lets the publish job reuse the Dockerfile
|
||||
# `npm ci` layer instead of rebuilding it from scratch behind the mirror (a
|
||||
# 7-minute image build versus 47). `docker image prune --force` above removes
|
||||
# only dangling images; BuildKit cache records live in the builder store, not
|
||||
# in dangling images, so nothing before this point touches them. Reclaim them
|
||||
# in tiers: drop entries nobody has used for 72 hours, re-measure, and escalate
|
||||
# to `--all` only when the runner is still below the threshold.
|
||||
docker builder prune --force --filter until=72h
|
||||
|
||||
TIERED_GIB="$(free_gib)"
|
||||
echo "docker root $DOCKER_ROOT has ${TIERED_GIB} GiB free after aged build-cache reclaim"
|
||||
if [ "$TIERED_GIB" -lt "$MINIMUM_FREE_GIB" ]; then
|
||||
echo "still below ${MINIMUM_FREE_GIB} GiB; escalating to a full BuildKit cache prune"
|
||||
docker builder prune --force --all
|
||||
# BuildKit layer cache is what lets the publish job reuse apt/pip/`npm ci`
|
||||
# layers instead of rebuilding behind a slow mirror (7-minute image builds
|
||||
# versus 47–60). `docker image prune --force` above removes only dangling
|
||||
# images; BuildKit cache lives in the builder store. Do not touch it while
|
||||
# the runner still has at least MINIMUM_FREE_GIB. Aged and full prunes are
|
||||
# reachable only after re-measuring and finding the disk actually short.
|
||||
CACHE_GIB="$(free_gib)"
|
||||
echo "docker root $DOCKER_ROOT has ${CACHE_GIB} GiB free before BuildKit reclaim"
|
||||
if [ "$CACHE_GIB" -lt "$MINIMUM_FREE_GIB" ]; then
|
||||
echo "below ${MINIMUM_FREE_GIB} GiB; pruning BuildKit cache unused for 72h"
|
||||
docker builder prune --force --filter until=72h
|
||||
TIERED_GIB="$(free_gib)"
|
||||
echo "docker root $DOCKER_ROOT has ${TIERED_GIB} GiB free after aged build-cache reclaim"
|
||||
if [ "$TIERED_GIB" -lt "$MINIMUM_FREE_GIB" ]; then
|
||||
echo "still below ${MINIMUM_FREE_GIB} GiB; escalating to a full BuildKit cache prune"
|
||||
docker builder prune --force --all
|
||||
fi
|
||||
else
|
||||
echo "keeping BuildKit layer cache; ${CACHE_GIB} GiB free"
|
||||
TIERED_GIB="$CACHE_GIB"
|
||||
fi
|
||||
|
||||
AFTER_GIB="$(free_gib)"
|
||||
|
||||
Reference in New Issue
Block a user