From 1726c48a7b6415ed721cfa0ea957c29f106837c3 Mon Sep 17 00:00:00 2001 From: Nathan Broadbent Date: Fri, 4 Dec 2026 17:36:05 +0000 Subject: [PATCH 1/2] Mirror: linux/amd64 copies only, under ghcr.io/docspring/visualci/mirror; prune unlisted copies after a week crane copied every platform of each multi-arch image: 12.3 GB of private (billed) package storage for 1.3 GB CI uses (caddy alone 4.9 GB, mostly Windows images). mirror.txt now pins each source's linux/amd64 manifest, so only that is copied. The copies move to the per-repo path every DocSpring repo will use (//mirror/, so each repo's workflow owns its packages); CI switches to them in a follow-up once this has run on main. A new step removes versions no longer listed once they're a week old. --- .github/mirror.txt | 29 ++++++++++++++++------------- .github/workflows/mirror.yml | 34 ++++++++++++++++++++++++++++++---- 2 files changed, 46 insertions(+), 17 deletions(-) diff --git a/.github/mirror.txt b/.github/mirror.txt index e0872d1b..6deccc79 100644 --- a/.github/mirror.txt +++ b/.github/mirror.txt @@ -1,13 +1,16 @@ -# Images CI pulls, copied from Docker Hub to ghcr.io/docspring/mirror/ by .github/workflows/mirror.yml, so a -# Docker Hub outage can't stop CI (4 Dec 2026: 502s from auth.docker.io failed a PR's journeys and images jobs). -# crane copy keeps the digest, so CI pins ghcr.io/docspring/mirror/@ to the same bytes as the source. -# To add or bump one: change its line here, merge, and once the workflow has run on main, use the new digest in CI. -# @ -postgres:17 docker.io/library/postgres@sha256:97fb53376be3e4fb1a8a61421daa69dcc3bf2fa39bda3259f5245f9a455af1a9 -rustfs:1.0.6 docker.io/rustfs/rustfs@sha256:ee717072290bec9b11abfc0365f8310b00df1cd9b3639943edae47bdef05044a -rust:1.99.1-trixie docker.io/library/rust@sha256:8a4e90c7946b74626488b1446f712c0fe0ed1a596cbd3d871684bc9c5433ae07 -node:24-trixie-slim docker.io/library/node@sha256:83079001d4ca6bf276035aa1c7b819b9542fc87a858a4fdc52ccc014bbf92143 -debian:trixie-slim docker.io/library/debian@sha256:8aa5a7bf5a1955bddbe7d74fcdd0b91ab30e74362a8b73af672b0481b35b44a0 -aws-cli:2.17.0 docker.io/amazon/aws-cli@sha256:643507c10ada7964ca6157b3d799f030b90577643da9955d319a77399ed80d73 -buildkit:buildx-stable-1 docker.io/moby/buildkit@sha256:baf6138eb8c37644800c7c913fba051e840ebb9ba13eaf92d92ef9a1712d0b4c -caddy:2.11.9 docker.io/library/caddy@sha256:4851e54a46b206517c574821bb5cc67f170d2156041e9fbc4c9193b45e84a75b +# Images CI pulls, copied from Docker Hub to ghcr.io/docspring/visualci/mirror/ by .github/workflows/mirror.yml, +# so a Docker Hub outage can't stop CI (4 Dec 2026: 502s from auth.docker.io failed a PR's journeys and images jobs). +# Each digest is the source's linux/amd64 image manifest (CI's runners), not its multi-platform index: crane copies +# just that, about a tenth of the storage (1.3 GB for this list, against 12.3 GB with every platform), and CI pins +# ghcr.io/docspring/visualci/mirror/@ to the same bytes as the source. +# To add or bump one: change its line here (`crane digest --platform linux/amd64 `), merge, and once the +# workflow has run on main, use the new digest in CI. The same format in every repo: //mirror/. +# @ +postgres:17 docker.io/library/postgres@sha256:e711be2c7ff64c9eb8883fc87571621be6caa2f943d825a49e5d20ac5b0221d7 +rustfs:1.0.6 docker.io/rustfs/rustfs@sha256:0dff1515b3c52b5ce8c5df2263420c7f93ae1c5d07cca79e19e57cff86b84c85 +rust:1.99.1-trixie docker.io/library/rust@sha256:3ddd9771c00ed2c214d75ba497ad28691ebeaf2279476068dd191cf39b4be033 +node:24-trixie-slim docker.io/library/node@sha256:efb444a6c8b45a1ebdd70974912147dc2be917714174f52334e236aa23c0e3a6 +debian:trixie-slim docker.io/library/debian@sha256:ab3b3c8c5159eebfca4376430132d53c4d425f869c765ecbe47177a030da575d +aws-cli:2.17.0 docker.io/amazon/aws-cli@sha256:7b7edf789765c22d75e61ad6f307c06950e15357b79ea1749104641ce3a11fec +buildkit:buildx-stable-1 docker.io/moby/buildkit@sha256:7583a0667093d941826bcd1d2878d6a360dfd08a82c93e6d6a6f6cce78801e12 +caddy:2.11.9 docker.io/library/caddy@sha256:fc9cbc100585871d18d4e451cca7021785c90a7006087427ae5ceb3e4efe6424 diff --git a/.github/workflows/mirror.yml b/.github/workflows/mirror.yml index 5caa04e9..7ad09edc 100644 --- a/.github/workflows/mirror.yml +++ b/.github/workflows/mirror.yml @@ -1,6 +1,7 @@ -# Copies the images in .github/mirror.txt from Docker Hub to ghcr.io/docspring/mirror/, keeping their digests, -# so CI pulls them from GitHub's own registry. Runs on main when the list changes, weekly to repair a deleted copy, and -# by hand. Only main runs it; CI pins the copies by digest, so a tag overwritten from a branch changes nothing CI runs. +# Copies the images in .github/mirror.txt from Docker Hub to ghcr.io/docspring/visualci/mirror/, keeping their +# digests, so CI pulls them from GitHub's own registry. Runs on main when the list changes, weekly to repair a deleted +# copy, and by hand. Only main runs it; CI pins the copies by digest, so a tag overwritten from a branch changes nothing +# CI runs. The packages are private: jobs log in with GITHUB_TOKEN (packages: read), forks' pull requests included. name: Mirror base images on: @@ -49,7 +50,7 @@ jobs: while read -r name source; do case "$name" in ''|\#*) continue ;; esac want=${source##*@} - dest=ghcr.io/docspring/mirror/$name + dest=ghcr.io/docspring/visualci/mirror/$name if [ "$(crane digest "$dest" 2>/dev/null)" = "$want" ]; then echo "up to date: $dest"; continue; fi for attempt in 1 2 3 4 5; do crane copy "$source" "$dest" && break @@ -59,3 +60,28 @@ jobs: if [ "$got" = "$want" ]; then echo "copied: $dest@$want"; else echo "::error::$dest is ${got:-missing}, want $want"; status=1; fi done < .github/mirror.txt exit $status + # Private packages are billed for storage: a copy no longer listed goes once it's a week old, so a branch still + # pinned to it has time to rebase. Only the workflow's own packages (this repo's mirror) are touched. + - name: Remove copies no longer listed + env: + GH_TOKEN: ${{ github.token }} + run: | + cutoff=$(date -u -d '7 days ago' +%Y-%m-%dT%H:%M:%SZ) + declare -A wanted + while read -r name source; do + case "$name" in ''|\#*) continue ;; esac + wanted[${name%%:*}]+=" ${source##*@}" + done < .github/mirror.txt + for image in "${!wanted[@]}"; do + package=visualci%2Fmirror%2F$image + gh api --paginate "orgs/DocSpring/packages/container/$package/versions" \ + --jq ".[] | select(.updated_at < \"$cutoff\") | \"\(.id) \(.name)\"" | + while read -r id digest; do + case " ${wanted[$image]} " in *" $digest "*) continue ;; esac + if gh api -X DELETE "orgs/DocSpring/packages/container/$package/versions/$id" >/dev/null; then + echo "removed visualci/mirror/$image@$digest" + else + echo "::warning::could not remove visualci/mirror/$image@$digest (version $id)" + fi + done + done From ad2ab2473697005e27b0004d2eac3b7bbd0db9fc Mon Sep 17 00:00:00 2001 From: Nathan Broadbent Date: Fri, 4 Dec 2026 17:38:54 +0000 Subject: [PATCH 2/2] Mirror prune: keep every digest the workflows and scripts pin, warn when listing fails From review: a bump or rename would otherwise delete the copy main's ci.yml still pins (versions older than a week are judged by updated_at, not by when they stopped being listed). Also: say that removed lines' packages are deleted by hand, and that the copies are amd64-only. --- .github/mirror.txt | 1 + .github/workflows/mirror.yml | 19 +++++++++++++++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/.github/mirror.txt b/.github/mirror.txt index 6deccc79..de129ec6 100644 --- a/.github/mirror.txt +++ b/.github/mirror.txt @@ -5,6 +5,7 @@ # ghcr.io/docspring/visualci/mirror/@ to the same bytes as the source. # To add or bump one: change its line here (`crane digest --platform linux/amd64 `), merge, and once the # workflow has run on main, use the new digest in CI. The same format in every repo: //mirror/. +# amd64 only: a job on an arm64 runner (vars.CI_RUNNER) or building for linux/arm64 needs a platform column first. # @ postgres:17 docker.io/library/postgres@sha256:e711be2c7ff64c9eb8883fc87571621be6caa2f943d825a49e5d20ac5b0221d7 rustfs:1.0.6 docker.io/rustfs/rustfs@sha256:0dff1515b3c52b5ce8c5df2263420c7f93ae1c5d07cca79e19e57cff86b84c85 diff --git a/.github/workflows/mirror.yml b/.github/workflows/mirror.yml index 7ad09edc..720deb8c 100644 --- a/.github/workflows/mirror.yml +++ b/.github/workflows/mirror.yml @@ -60,8 +60,10 @@ jobs: if [ "$got" = "$want" ]; then echo "copied: $dest@$want"; else echo "::error::$dest is ${got:-missing}, want $want"; status=1; fi done < .github/mirror.txt exit $status - # Private packages are billed for storage: a copy no longer listed goes once it's a week old, so a branch still - # pinned to it has time to rebase. Only the workflow's own packages (this repo's mirror) are touched. + # Private packages are billed for storage: a copy that's neither listed nor pinned anywhere in this checkout's + # workflows or scripts goes once it's a week old (pinned ones stay, so a bump never breaks main's CI before it + # switches; the week gives branches time to rebase). Only images still listed are looked at: when a line goes, + # delete its package by hand. Only the workflow's own packages (this repo's mirror) are touched. - name: Remove copies no longer listed env: GH_TOKEN: ${{ github.token }} @@ -72,10 +74,19 @@ jobs: case "$name" in ''|\#*) continue ;; esac wanted[${name%%:*}]+=" ${source##*@}" done < .github/mirror.txt + while IFS=@ read -r image digest; do + wanted[${image%%:*}]+=" $digest" + done < <(grep -rhoE 'visualci/mirror/[a-z0-9._-]+(:[A-Za-z0-9._-]+)?@sha256:[0-9a-f]{64}' .github scripts docker | + sed 's|^visualci/mirror/||' | sort -u) for image in "${!wanted[@]}"; do package=visualci%2Fmirror%2F$image - gh api --paginate "orgs/DocSpring/packages/container/$package/versions" \ - --jq ".[] | select(.updated_at < \"$cutoff\") | \"\(.id) \(.name)\"" | + if ! versions=$(gh api --paginate "orgs/DocSpring/packages/container/$package/versions" \ + --jq ".[] | select(.updated_at < \"$cutoff\") | \"\(.id) \(.name)\""); then + echo "::warning::could not list visualci/mirror/$image's versions, so none were removed" + continue + fi + [ -n "$versions" ] || continue + printf '%s\n' "$versions" | while read -r id digest; do case " ${wanted[$image]} " in *" $digest "*) continue ;; esac if gh api -X DELETE "orgs/DocSpring/packages/container/$package/versions/$id" >/dev/null; then