Files
kevinveenbirkenbachandClaude Opus 5.5 08c007dad8 fix(image): prune the host build cache to INFINITO_BUILD_CACHE_MAX_SIZE after every build
Main never bounded the host Docker build cache: on 2026-11-11 it held
99 GB, 63 GB of it unused for more than 12 h (15 overnight core image
builds). The cap already exists on the IAM line as part of 4014385f6a
(092 phase 1); this ports only its build-cache slice to main.

- scripts/image/prune.sh (byte-identical to 4014385f6a) runs
  docker builder prune --force with --max-used-space, or --keep-storage
  on older engines, at INFINITO_BUILD_CACHE_MAX_SIZE, and fails loudly
  when the engine knows neither flag.
- scripts/image/build.sh calls it after every build.
- default.env sets the cap to 20g; the env passthrough exports it.

Every existing checkout needs one make dotenv after this change: until
then make build stops at the final prune step with Run 'make dotenv'.
The shared cap also evicts other checkouts' build layers, which costs
rebuild time, not correctness.

🎯 Fix: 90 %
💥 Break: 8 %
💸 Cost: 100 %
⏱️ Time: 100 %
🛡️ Security: ~100 %
🏆 Score: 83
🚦 Gate: ⛔ break 8 % > 5 (operator approved)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 10:07:57 +00:00

18 lines
770 B
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
: "${INFINITO_BUILD_CACHE_MAX_SIZE:?Run 'make dotenv' to generate the .env single source of truth}"
prune_help="$(docker builder prune --help)"
if grep -q -- '--max-used-space' <<<"${prune_help}"; then
keep_flag="--max-used-space"
elif grep -q -- '--keep-storage' <<<"${prune_help}"; then
keep_flag="--keep-storage"
else
echo "[build] ERROR: 'docker builder prune' accepts neither --max-used-space nor --keep-storage; cannot cap the build cache at INFINITO_BUILD_CACHE_MAX_SIZE=${INFINITO_BUILD_CACHE_MAX_SIZE}" >&2
exit 1
fi
echo "[build] Pruning the build cache to INFINITO_BUILD_CACHE_MAX_SIZE=${INFINITO_BUILD_CACHE_MAX_SIZE} (${keep_flag})"
docker builder prune --force "${keep_flag}" "${INFINITO_BUILD_CACHE_MAX_SIZE}"