@@ -8,33 +8,77 @@ if [[ ! $# -eq 1 ]]; then
88 exit 1
99fi
1010
11+ export HTTP_TIMEOUT=600 # Timeout in seconds (default is typically 90)
12+ export REGISTRY_TIMEOUT=600 # Registry specific timeout
13+
14+ output_dir=$1
1115mkdir -p $1
16+
1217# Download all the docker images into $1, and append its name to an index.txt
1318# If this errors out for you, copy default-policy.json from the skopeo repo to
1419# /etc/containers/policy.json
1520while IFS= read -r image; do
16- # sanitize the image file name, replace slashes with underscores, suffix with .tar
17- image_filename=$( sed -r " s/[:\/]/_/g" <<< $image )
18- image_path=$( realpath $1 ) /${image_filename} .tar
19- if [[ -e $image_path ]]; then
20- echo " Skipping $image_filename …"
21+
22+ # sanitize the image file name, replace slashes with underscores, suffix with .tar
23+ image_filename=$( sed -r " s/[:\/]/_/g" <<< " $image" )
24+ image_path=" $( realpath " $1 " ) /${image_filename} .tar"
25+
26+ if [[ -s " $image_path " ]]; then
27+ echo " Skipping $image_filename …"
28+ continue
29+ fi
30+
31+ echo " Fetching $image_filename …"
32+
33+ # All of these images should be publicly fetchable, especially given we
34+ # ship public tarballs containing these images.
35+ # ci.sh already honors DOCKER_LOGIN, so do the same here, otherwise
36+ # fallback to unauthorized fetching.
37+
38+ # If an image has both a tag and digest, remove the tag. Return the original if there is no match.
39+ image_trimmed=$( echo " $image " | sed -E ' s/(.+)(:.+(@.+))/\1\3/' )
40+
41+ tmp_path=" ${image_path} .tmp"
42+ rm -f " $tmp_path "
43+
44+ success=false
45+
46+ for attempt in {1..5}; do
47+ echo " Attempt $attempt /5 for $image_trimmed "
48+
49+ if [[ -n " ${DOCKER_LOGIN:- } " && " $image " =~ quay.io/wire ]]; then
50+ skopeo copy --insecure-policy \
51+ --src-creds " $DOCKER_LOGIN " \
52+ --retry-times 10 \
53+ " docker://$image_trimmed " \
54+ " docker-archive:${tmp_path} " \
55+ --additional-tag " $image " || rc=$?
2156 else
22- echo " Fetching $image_filename …"
23-
24- # All of these images should be publicly fetchable, especially given we
25- # ship public tarballs containing these images.
26- # ci.sh already honors DOCKER_LOGIN, so do the same here, otherwise
27- # fallback to unauthorized fetching.
28-
29- # If an image has both a tag and digest, remove the tag. Return the original if there is no match.
30- image_trimmed=$( echo " $image " | sed -E ' s/(.+)(:.+(@.+))/\1\3/' )
31- if [[ -n " ${DOCKER_LOGIN:- } " && " $image " =~ quay.io/wire ]]; then
32- skopeo copy --insecure-policy --src-creds " $DOCKER_LOGIN " \
33- docker://$image_trimmed docker-archive:${image_path} --additional-tag $image
34- else
35- skopeo copy --insecure-policy \
36- docker://$image_trimmed docker-archive:${image_path} --additional-tag $image
37- fi
38- echo " ${image_filename} .tar" >> $( realpath " $1 " ) /index.txt
57+ skopeo copy --insecure-policy \
58+ --retry-times 10 \
59+ " docker://$image_trimmed " \
60+ " docker-archive:${tmp_path} " \
61+ --additional-tag " $image " || rc=$?
62+ fi
63+
64+ rc=$?
65+
66+ if [[ $rc -eq 0 && -s " $tmp_path " ]]; then
67+ mv " $tmp_path " " $image_path "
68+ success=true
69+ break
3970 fi
71+
72+ echo " Fetch failed for $image_trimmed with rc=$rc ; retrying…"
73+ rm -f " $tmp_path "
74+ sleep $(( attempt * 20 ))
75+ done
76+
77+ if [[ " $success " != true ]]; then
78+ echo " ERROR: failed to fetch $image after retries" >&2
79+ exit 1
80+ fi
81+
82+ echo " ${image_filename} .tar" >> " $( realpath " $1 " ) /index.txt"
83+ create-build-entry " $image " " $output_dir "
4084done
0 commit comments