fix(ci): copy the nightly images to public ECR by digest, with retries (#9972)

Public ECR dropped a blob upload in the nightly run 46814301866 ("The upload with id ... does not exist"). The nightly pushed each image to Docker Hub and public ECR in one buildx step, so the step failed and the compat nightly image was skipped on both registries. This is the failure #9840 fixed in release.yml.

The two pushes now go to Docker Hub only. A step after them copies each image to public ECR by the digest its push produced, with docker buildx imagetools create, and retries a dropped upload. It runs when either push produced a digest, so a failed compat push still leaves the native nightly on public ECR. CI runs the new tests for the script and for the Docker Hub-only pushes.

Signed-off-by: Hector Ventura <hectorvent@gmail.com>
This commit is contained in:
Hector Ventura authored and GitHub committed 2026-12-02 00:20:47 -06:00
1 parent a61eca22a8
commit 26b97da9ec
4 files changed
+192 -5

No files matched your search

+65
View File
@@ -0,0 +1,65 @@
#!/usr/bin/env bash
# Copies the nightly images from Docker Hub to public ECR by digest.
#
# VERSION=12012026 NATIVE_DIGEST=sha256:... COMPAT_DIGEST=sha256:... nightly-images-mirror.sh
#
# nightly.yml pushes each image to Docker Hub only and passes the digest each push produced. This
# points public.ecr.aws/floci/floci:nightly and :nightly-<version> at the native digest, and the
# -compat pair at the compat digest, with `docker buildx imagetools create`: a registry-to-registry
# copy, so nothing is rebuilt and both registries serve the same digest. An empty digest means that
# image was not pushed, and its tags are left alone.
#
# Public ECR drops a blob upload now and then ("The upload with id ... does not exist", nightly run
# 46814301866), so each copy is retried; RETRY_DELAYS lists the waits in seconds. A tag that still
# fails does not stop the others; the script exits non-zero at the end.
set -euo pipefail
VERSION=${VERSION:?VERSION is required (mmddyyyy)}
SOURCE=${SOURCE_REPO:-floci/floci}
MIRROR=${MIRROR_REPO:-public.ecr.aws/floci/floci}
DOCKER=${DOCKER:-docker}
read -ra DELAYS <<< "${RETRY_DELAYS:-15 30 60}"
SUMMARY=${GITHUB_STEP_SUMMARY:-/dev/null}
NATIVE_DIGEST=${NATIVE_DIGEST:-}
COMPAT_DIGEST=${COMPAT_DIGEST:-}
fail() {
echo "::error::$1" >&2
exit 1
}
[[ $VERSION =~ ^[0-9]{8}$ ]] || fail "'$VERSION' is not a nightly version (mmddyyyy)"
[ -n "$NATIVE_DIGEST$COMPAT_DIGEST" ] || fail "no digest given: nothing was pushed to copy"
for digest in "$NATIVE_DIGEST" "$COMPAT_DIGEST"; do
[ -z "$digest" ] || [[ $digest =~ ^sha256:[0-9a-f]{64}$ ]] || fail "'$digest' is not a sha256 digest"
done
copy() {
local tag=$1 digest=$2 attempt=0
while true; do
if "$DOCKER" buildx imagetools create --tag "$MIRROR:$tag" "$SOURCE@$digest"; then
echo "- \`$tag\`: \`$digest\`" >> "$SUMMARY"
return 0
fi
if [ "$attempt" -ge "${#DELAYS[@]}" ]; then
echo "::error::could not copy $SOURCE@$digest to $MIRROR:$tag after $((attempt + 1)) attempts" >&2
echo "- \`$tag\`: copy failed" >> "$SUMMARY"
return 1
fi
echo "::warning::copy to $MIRROR:$tag failed; retrying in ${DELAYS[$attempt]}s" >&2
sleep "${DELAYS[$attempt]}"
attempt=$((attempt + 1))
done
}
echo "### Public ECR nightly tags" >> "$SUMMARY"
failed=0
if [ -n "$NATIVE_DIGEST" ]; then
copy nightly "$NATIVE_DIGEST" || failed=1
copy "nightly-$VERSION" "$NATIVE_DIGEST" || failed=1
fi
if [ -n "$COMPAT_DIGEST" ]; then
copy nightly-compat "$COMPAT_DIGEST" || failed=1
copy "nightly-$VERSION-compat" "$COMPAT_DIGEST" || failed=1
fi
exit "$failed"