build-cran-binaries/justfile
pat-s 09536cddd6
Some checks failed
ci/crow/cron/weekly-audit-missing/3 Pipeline was successful
ci/crow/cron/weekly-audit-missing/4 Pipeline was successful
ci/crow/cron/weekly-audit-missing/5 Pipeline was successful
ci/crow/cron/weekly-audit-missing/6 Pipeline was successful
ci/crow/cron/weekly-audit-missing/7 Pipeline was successful
ci/crow/cron/weekly-audit-missing/8 Pipeline was successful
ci/crow/cron/weekly-audit-missing/9 Pipeline was successful
ci/crow/cron/weekly-audit-missing/10 Pipeline was successful
ci/crow/cron/weekly-audit-missing/11 Pipeline was successful
ci/crow/cron/weekly-audit-missing/12 Pipeline was successful
ci/crow/cron/weekly-audit-missing/13 Pipeline was successful
ci/crow/cron/weekly-audit-missing/14 Pipeline was successful
ci/crow/cron/weekly-audit-missing/15 Pipeline was successful
ci/crow/cron/weekly-audit-missing/16 Pipeline was successful
ci/crow/cron/weekly-rebuild-missing/3 Pipeline was successful
ci/crow/cron/weekly-rebuild-missing/4 Pipeline was successful
ci/crow/cron/weekly-rebuild-missing/1 Pipeline was canceled
ci/crow/cron/weekly-rebuild-missing/6 Pipeline was successful
ci/crow/cron/weekly-rebuild-missing/7 Pipeline was successful
ci/crow/cron/weekly-rebuild-missing/8 Pipeline was successful
ci/crow/cron/weekly-rebuild-missing/2 Pipeline was canceled
ci/crow/cron/weekly-rebuild-missing/5 Pipeline was successful
ci/crow/cron/weekly-rebuild-missing/10 Pipeline was successful
ci/crow/cron/weekly-rebuild-missing/11 Pipeline was successful
ci/crow/cron/weekly-rebuild-missing/12 Pipeline was successful
ci/crow/cron/weekly-rebuild-missing/13 Pipeline was successful
ci/crow/cron/weekly-rebuild-missing/9 Pipeline was canceled
ci/crow/cron/weekly-rebuild-missing/14 Pipeline was successful
ci/crow/cron/process-updates/15 Pipeline failed
ci/crow/cron/process-updates/11 Pipeline was canceled
ci/crow/cron/process-updates/16 Pipeline was canceled
ci/crow/cron/process-updates/12 Pipeline was successful
ci/crow/cron/process-updates/5 Pipeline was successful
ci/crow/cron/process-updates/6 Pipeline was successful
ci/crow/cron/process-updates/18 Pipeline was successful
ci/crow/cron/process-updates/17 Pipeline was canceled
ci/crow/cron/process-updates/1 Pipeline was canceled
ci/crow/cron/process-updates/2 Pipeline was canceled
ci/crow/cron/process-updates/8 Pipeline was canceled
ci/crow/manual/build-all-versions-install-deps/2 Pipeline was successful
ci/crow/cron/process-updates/9 Pipeline was canceled
ci/crow/cron/process-updates/3 Pipeline was canceled
ci/crow/cron/process-updates/7 Pipeline was successful
ci/crow/cron/process-updates/10 Pipeline was canceled
ci/crow/manual/build-all-versions/7 Pipeline was canceled
ci/crow/manual/build-all-versions/6 Pipeline failed
ci/crow/manual/build-all-versions/8 Pipeline was canceled
ci/crow/manual/build-all-versions/5 Pipeline was canceled
ci/crow/cron/process-updates/4 Pipeline was canceled
ci/crow/cron/process-updates/14 Pipeline was canceled
ci/crow/cron/process-updates/13 Pipeline was successful
feat(build): raise BuildKit cache-mount budget for remote builders (#112)
BuildKit's default GC caps the ephemeral cache tier — `RUN --mount=type=cache` mounts, local build context, git checkouts — at a hardcoded **512 MB** (shown as `488.3 MiB` in `buildx inspect`).
Across our 7-distro build matrix that fills instantly and forces re-downloads of system + R packages on every rebuild.

## Changes

- **`docker/buildkitd.toml`** (new) — GC config passed via `--config` when creating the `docker-container` builders `artemis` (amd64) and `gaia` (arm64):
  - cache-mount tier: **512 MB → 8 GB**, retained 7 days
  - total cache bounded at **40 GB** with **20 GB min-free**
- **`justfile`** — document the `--config docker/buildkitd.toml` flag on the builder-create commands so a recreate does not silently revert to the 512 MB default.

## Notes

- Limits are absolute (not `%`) because the two hosts differ ~6× in free space (Hetzner ~42 GiB free vs Mac mini ~279 GiB). The 20 GB min-free is the safety valve on the disk-tight Hetzner host; the old default wanted 64 GiB free, which does not exist there.
- Both live builders were already recreated with this config and verified running.

Reviewed-on: #112
2026-07-08 08:22:03 +00:00

75 lines
3.6 KiB
Makefile

# Local helpers for build-cran-binaries.
#
# `rebuild` (re)builds specific versions of a single package on a given OS/arch
# by dispatching to a remote buildx builder (the build runs there, not locally).
# Sensitivity is auto-detected: risky packages land in the per-minor slot
# (contrib/<x.y>/), everything else in the generic slot; the touched index is
# refreshed so the result is immediately servable.
#
# Prerequisites:
# - buildx builders named `artemis` (amd64) and `gaia` (arm64), created with the
# docker-container driver (runs BuildKit on the remote host's docker daemon over
# SSH). The default `remote` driver does NOT work with an ssh:// docker host.
# Pass --config docker/buildkitd.toml so BuildKit's GC keeps a usable cache
# (the default caps the cache-mount tier at 512 MB, forcing re-downloads).
# docker buildx create --name artemis --driver docker-container --config docker/buildkitd.toml ssh://<user@host-amd64>
# docker buildx create --name gaia --driver docker-container --config docker/buildkitd.toml ssh://<user@host-arm64>
# - exported secrets: B2_S3_ACCESS_KEY, B2_S3_SECRET_KEY, PGPASS (GITHUB_PAT optional)
#
# Overridable (env or `just VAR=… rebuild …`):
# R_VERSION (default 4.5.3) — selects the R minor → the per-minor slot
# AMD64_BUILDER / ARM64_BUILDER — buildx builder names
#
# Examples:
# just rebuild alpine 3.23 amd64 rlang 1.1.4 1.1.3
# just rebuild redhat 10 arm64 data.table 1.15.4
# R_VERSION=4.4.3 just rebuild ubuntu noble amd64 Rcpp 1.0.12
r_version := env_var_or_default("R_VERSION", "4.5.3")
amd64_builder := env_var_or_default("AMD64_BUILDER", "artemis")
arm64_builder := env_var_or_default("ARM64_BUILDER", "gaia")
# (re)build PACKAGE at one or more VERSIONS on OS/TAG/ARCH via a remote builder
rebuild os tag arch package *versions:
#!/usr/bin/env bash
set -euo pipefail
if [ -z "{{ versions }}" ]; then
echo "error: provide at least one version, e.g. just rebuild alpine 3.23 amd64 rlang 1.1.4" >&2
exit 1
fi
case "{{ arch }}" in
amd64) builder="{{ amd64_builder }}" ;;
arm64) builder="{{ arm64_builder }}" ;;
*) echo "error: arch must be 'amd64' or 'arm64'" >&2; exit 1 ;;
esac
# Accept TF_VAR_-prefixed names (direnv) or plain names.
export B2_S3_ACCESS_KEY="${B2_S3_ACCESS_KEY:-${TF_VAR_B2_S3_ACCESS_KEY:-}}"
export B2_S3_SECRET_KEY="${B2_S3_SECRET_KEY:-${TF_VAR_B2_S3_SECRET_KEY:-}}"
: "${B2_S3_ACCESS_KEY:?set B2_S3_ACCESS_KEY or TF_VAR_B2_S3_ACCESS_KEY}"
: "${B2_S3_SECRET_KEY:?set B2_S3_SECRET_KEY or TF_VAR_B2_S3_SECRET_KEY}"
: "${PGPASS:?set PGPASS}"
secret_args=(
--secret id=b2_access,env=B2_S3_ACCESS_KEY
--secret id=b2_secret,env=B2_S3_SECRET_KEY
--secret id=pgpass,env=PGPASS
)
# GITHUB_PAT is optional (raises the GitHub API rate limit); pass only if set.
if [ -n "${GITHUB_PAT:-}" ]; then
secret_args+=(--secret id=github_pat,env=GITHUB_PAT)
fi
echo "Dispatching build of {{ package }} ({{ versions }}) on {{ os }}:{{ tag }}/{{ arch }} (R {{ r_version }}) to builder '$builder'"
docker buildx build \
--builder "$builder" \
--platform "linux/{{ arch }}" \
--no-cache \
--progress=plain \
--output type=cacheonly \
"${secret_args[@]}" \
--build-arg OS="{{ os }}" \
--build-arg OS_VERSION="{{ tag }}" \
--build-arg R_VERSION="{{ r_version }}" \
--build-arg PACKAGE="{{ package }}" \
--build-arg VERSIONS="{{ versions }}" \
--build-arg CACHEBUST="$(date +%s)" \
-f docker/build-one.Dockerfile \
local