-
Notifications
You must be signed in to change notification settings - Fork 284
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add RD_USE_GHCR_IMAGES option to BATS to pull images from ghcr.io
This avoids hitting the pull rate limit when running multiple full BATS runs in sequence, especially if not logged into Docker Hub. Pull rate limit for docker.io is 100 pulls / 6 hours, or twice that when authenticated. Signed-off-by: Jan Dubois <jan.dubois@suse.com>
- Loading branch information
Showing
15 changed files
with
159 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
github | ||
https | ||
skopeo | ||
ssh | ||
ubuntu | ||
workarounds |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#!/bin/bash | ||
|
||
# Mirror Docker Hub images to ghcr.io to avoid pull limits during testing. | ||
|
||
# The script uses skopeo instead of docker pull/push because it needs to | ||
# copy all images of the repo, and not just the one for the current platform. | ||
# | ||
# Log into ghcr.io with a personal access token with write:packages scope: | ||
# echo $PAT | skopeo login ghcr.io -u $USER --password-stdin | ||
# echo $PASS | skopeo login docker.io -u $USER --password-stdin | ||
# Remove credentials: | ||
# skopeo logout --all | ||
|
||
# TODO TODO TODO | ||
# The package visibility needs to be changed to "public". | ||
# I've not found any tool/API to do this from the commandline, | ||
# so I did this manually via the web UI. | ||
# At the very least we should check that the images are accessible | ||
# when logged out of ghcr.io. | ||
# TODO TODO TODO | ||
|
||
# TODO TODO TODO | ||
# Figure out a way to copy only the amd64 and arm64 images, but not the rest. | ||
# skopeo doesn't seem to support this yet without additional scripting to parse | ||
# the manifests. And then we would need to test if we can copy a "sparse" manifest | ||
# to ghcr.io when not all referenced images actually exist. | ||
# TODO TODO TODO | ||
|
||
set -o errexit -o nounset -o pipefail | ||
set +o xtrace | ||
|
||
if ! command -v skopeo >/dev/null; then | ||
echo "This script requires the 'skopeo' utility to be installed" | ||
exit 1 | ||
fi | ||
|
||
source "$(dirname "${BASH_SOURCE[0]}")/../tests/helpers/images.bash" | ||
|
||
# IMAGES is setup by ../tests/helpers/images.bash | ||
# shellcheck disable=SC2153 | ||
for IMAGE in "${IMAGES[@]}"; do | ||
echo "===== Copying $IMAGE =====" | ||
skopeo copy --all "docker://$IMAGE" "docker://$GHCR_REPO/$IMAGE" | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# These images have been mirrored to ghcr.io (using bats/scripts/ghcr-mirror.sh) | ||
# to avoid hitting Docker Hub pull limits during testing. | ||
|
||
# TODO TODO TODO | ||
# The python image is huge (10GB across all platforms). We should either pin the | ||
# tag, or replace it with a different image for testing, so we don't have to mirror | ||
# the images to ghcr.io every time we run the mirror script. | ||
# TODO TODO TODO | ||
|
||
# Any time you add an image here you need to re-run the mirror script! | ||
IMAGES=(busybox nginx python ruby tonistiigi/binfmt registry:2.8.1) | ||
|
||
GHCR_REPO=ghcr.io/rancher-sandbox/bats | ||
|
||
# Create IMAGE_FOO_BAR=foo/bar:tag variables | ||
for IMAGE in "${IMAGES[@]}"; do | ||
VAR="IMAGE_$(echo "$IMAGE" | sed 's/:.*//' | tr '[:lower:]' '[:upper:]' | tr / _)" | ||
# file may be loaded outside BATS environment | ||
if [ "$(type -t using_ghcr_images)" = "function" ] && using_ghcr_images; then | ||
eval "$VAR=$GHCR_REPO/$IMAGE" | ||
else | ||
eval "$VAR=$IMAGE" | ||
fi | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.