1
0
mirror of https://github.com/openshift/openshift-docs.git synced 2026-02-05 12:46:18 +01:00
Files
openshift-docs/modules/microshift-upload-cont2-mirror-script.adoc
2023-10-09 16:37:03 +00:00

27 lines
895 B
Plaintext

[source,sh]
----
# Use timestamp and counter as a tag on the target images to avoid
# their overwrite by the 'latest' automatic tagging
image_tag=mirror-$(date +%y%m%d%H%M%S)
image_cnt=1
pushd "${IMAGE_LOCAL_DIR}" >/dev/null
while read -r src_manifest ; do
# Remove the manifest.json file name
src_img=$(dirname "${src_manifest}")
# Add the target registry prefix and remove SHA
dst_img="${TARGET_REGISTRY}/${src_img}"
dst_img=$(echo "${dst_img}" | awk -F'@' '{print $1}')
# Run the image upload command
echo "Uploading '${src_img}' to '${dst_img}'"
skopeo copy --all --quiet \
--preserve-digests \
--authfile "${IMAGE_PULL_FILE}" \
dir://"${IMAGE_LOCAL_DIR}/${src_img}" docker://"${dst_img}:${image_tag}-${image_cnt}"
# Increment the counter
(( image_cnt += 1 ))
done < <(find . -type f -name manifest.json -printf '%P\n')
popd >/dev/null
----