From aa18e4d4549ebfee1a4254f10f8ab84ae7331c4a Mon Sep 17 00:00:00 2001 From: Nathan Broadbent Date: Fri, 4 Dec 2026 23:49:54 +1300 Subject: [PATCH 1/2] CI: mirror base images from Docker Hub to ghcr.io/docspring/mirror, pinned by digest A Docker Hub outage (502s from auth.docker.io) failed #194's journeys and images jobs. This workflow copies the images CI pulls to GitHub's registry with crane, keeping their digests; a follow-up points CI at the copies. --- .github/mirror.txt | 12 ++++++++ .github/workflows/mirror.yml | 57 ++++++++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+) create mode 100644 .github/mirror.txt create mode 100644 .github/workflows/mirror.yml diff --git a/.github/mirror.txt b/.github/mirror.txt new file mode 100644 index 00000000..ea1a33bc --- /dev/null +++ b/.github/mirror.txt @@ -0,0 +1,12 @@ +# 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 diff --git a/.github/workflows/mirror.yml b/.github/workflows/mirror.yml new file mode 100644 index 00000000..4c97def5 --- /dev/null +++ b/.github/workflows/mirror.yml @@ -0,0 +1,57 @@ +# 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 writes the mirror: a pull request's token can't publish packages. +name: Mirror base images + +on: + push: + branches: [main] + paths: [.github/mirror.txt, .github/workflows/mirror.yml] + schedule: + - cron: "17 3 * * 1" + workflow_dispatch: + +permissions: + contents: read + packages: write + +concurrency: + group: mirror-base-images + cancel-in-progress: false + +jobs: + mirror: + runs-on: ubuntu-latest + timeout-minutes: 30 + steps: + - uses: actions/checkout@v4 + - name: Install crane (go-containerregistry), checksum verified + env: + GH_TOKEN: ${{ github.token }} + VERSION: v0.22.1 + run: | + cd "$RUNNER_TEMP" + gh release download "$VERSION" -R google/go-containerregistry \ + -p go-containerregistry_Linux_x86_64.tar.gz -p checksums.txt + grep ' go-containerregistry_Linux_x86_64.tar.gz$' checksums.txt | sha256sum -c - + tar -xzf go-containerregistry_Linux_x86_64.tar.gz crane + echo "$RUNNER_TEMP" >> "$GITHUB_PATH" + - run: printf '%s' "$TOKEN" | crane auth login ghcr.io -u "$GITHUB_ACTOR" --password-stdin + env: + TOKEN: ${{ github.token }} + - name: Copy each image, retrying Docker Hub's hiccups + run: | + status=0 + while read -r name source; do + case "$name" in ''|\#*) continue ;; esac + want=${source##*@} + dest=ghcr.io/docspring/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 + echo "attempt $attempt failed; retrying in $((attempt * 20)) s"; sleep $((attempt * 20)) + done + got=$(crane digest "$dest" 2>/dev/null || true) + 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 From a13ce8eececae86b20144e5ff51eda4b10716cb2 Mon Sep 17 00:00:00 2001 From: Nathan Broadbent Date: Fri, 4 Dec 2026 23:52:42 +1300 Subject: [PATCH 2/2] mirror workflow: pinned crane checksum, persist-credentials false, honest comment, no sleep after the last retry --- .github/workflows/mirror.yml | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/.github/workflows/mirror.yml b/.github/workflows/mirror.yml index 4c97def5..5caa04e9 100644 --- a/.github/workflows/mirror.yml +++ b/.github/workflows/mirror.yml @@ -1,6 +1,6 @@ # 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 writes the mirror: a pull request's token can't publish packages. +# by hand. Only main runs it; CI pins the copies by digest, so a tag overwritten from a branch changes nothing CI runs. name: Mirror base images on: @@ -25,15 +25,19 @@ jobs: timeout-minutes: 30 steps: - uses: actions/checkout@v4 + with: + persist-credentials: false - name: Install crane (go-containerregistry), checksum verified env: GH_TOKEN: ${{ github.token }} VERSION: v0.22.1 + SHA256: 0ab7a1d6932a213aed964ce97666c3077fe691c8606413674a8b3e0b9ec4cda0 run: | cd "$RUNNER_TEMP" gh release download "$VERSION" -R google/go-containerregistry \ - -p go-containerregistry_Linux_x86_64.tar.gz -p checksums.txt - grep ' go-containerregistry_Linux_x86_64.tar.gz$' checksums.txt | sha256sum -c - + -p go-containerregistry_Linux_x86_64.tar.gz + # Pinned here, not read from the release's own checksums.txt, so a replaced release can't pass. + echo "$SHA256 go-containerregistry_Linux_x86_64.tar.gz" | sha256sum -c - tar -xzf go-containerregistry_Linux_x86_64.tar.gz crane echo "$RUNNER_TEMP" >> "$GITHUB_PATH" - run: printf '%s' "$TOKEN" | crane auth login ghcr.io -u "$GITHUB_ACTOR" --password-stdin @@ -49,7 +53,7 @@ jobs: 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 - echo "attempt $attempt failed; retrying in $((attempt * 20)) s"; sleep $((attempt * 20)) + [ "$attempt" = 5 ] || { echo "attempt $attempt failed; retrying in $((attempt * 20)) s"; sleep $((attempt * 20)); } done got=$(crane digest "$dest" 2>/dev/null || true) if [ "$got" = "$want" ]; then echo "copied: $dest@$want"; else echo "::error::$dest is ${got:-missing}, want $want"; status=1; fi