Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 17 additions & 13 deletions .github/mirror.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
# Images CI pulls, copied from Docker Hub to ghcr.io/docspring/mirror/<name> 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/<name>@<digest> 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.
# <name:tag> <source>@<digest>
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/<name> 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/<name>@<digest> to the same bytes as the source.
# To add or bump one: change its line here (`crane digest --platform linux/amd64 <image>`), merge, and once the
# workflow has run on main, use the new digest in CI. The same format in every repo: <org>/<repo>/mirror/<name>.
# amd64 only: a job on an arm64 runner (vars.CI_RUNNER) or building for linux/arm64 needs a platform column first.
# <name:tag> <source>@<linux/amd64 manifest digest>
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
45 changes: 41 additions & 4 deletions .github/workflows/mirror.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Copies the images in .github/mirror.txt from Docker Hub to ghcr.io/docspring/mirror/<name>, 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/<name>, 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:
Expand Down Expand Up @@ -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
Expand All @@ -59,3 +60,39 @@ 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 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 }}
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
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
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
echo "removed visualci/mirror/$image@$digest"
else
echo "::warning::could not remove visualci/mirror/$image@$digest (version $id)"
fi
done
done
Loading