|
1 | 1 | // Module included in the following assemblies: |
2 | 2 | // |
3 | | -// * microshift/running_applications/microshift-deploy-with-mirror-registry.adoc |
| 3 | +// * microshift/pmicroshift_install_rpm_ostree/microshift-deploy-with-mirror-registry.adoc |
4 | 4 |
|
5 | 5 | :_mod-docs-content-type: PROCEDURE |
6 | 6 | [id="microshift-uploading-container-images-to-mirror_{context}"] |
@@ -39,38 +39,29 @@ $ IMAGE_LOCAL_DIR=~/microshift-containers |
39 | 39 |
|
40 | 40 | . Set the environment variables pointing to the mirror registry URL for uploading the container images: |
41 | 41 | + |
42 | | -[source,terminal] |
| 42 | +[source,terminal,subs="+quotes"] |
43 | 43 | ---- |
44 | | -$ TARGET_REGISTRY=<registry_host>:<port> <1> |
| 44 | +$ TARGET_REGISTRY=_<registry_host>:<port>_ # <1> |
45 | 45 | ---- |
46 | | -<1> Replace `<registry_host>:<port>` with the host name and port of your mirror registry server. |
| 46 | +<1> Replace `_<registry_host>:<port>_` with the host name and port of your mirror registry server. |
47 | 47 |
|
48 | 48 | . Run the following script to upload the container images to the `${TARGET_REGISTRY}` mirror registry: |
49 | 49 | + |
50 | 50 | [source,terminal] |
51 | 51 | ---- |
52 | | -image_tag=mirror-$(date +%y%m%d%H%M%S) |
53 | | -image_cnt=1 |
54 | | - # Uses timestamp and counter as a tag on the target images to avoid |
55 | | - # their overwrite by the 'latest' automatic tagging |
56 | | - |
57 | 52 | pushd "${IMAGE_LOCAL_DIR}" >/dev/null |
58 | 53 | while read -r src_manifest ; do |
59 | | - # Remove the manifest.json file name |
60 | | - src_img=$(dirname "${src_manifest}") |
61 | | - # Add the target registry prefix and remove SHA |
62 | | - dst_img="${TARGET_REGISTRY}/${src_img}" |
63 | | - dst_img=$(echo "${dst_img}" | awk -F'@' '{print $1}') |
64 | | - |
65 | | - # Run the image upload command |
66 | | - echo "Uploading '${src_img}' to '${dst_img}'" |
67 | | - skopeo copy --all --quiet \ |
68 | | - --preserve-digests \ |
69 | | - --authfile "${IMAGE_PULL_FILE}" \ |
70 | | - dir://"${IMAGE_LOCAL_DIR}/${src_img}" docker://"${dst_img}:${image_tag}-${image_cnt}" |
71 | | - # Increment the counter |
72 | | - (( image_cnt += 1 )) |
73 | | - |
| 54 | + local src_img |
| 55 | + src_img=$(dirname "${src_manifest}") |
| 56 | + # Add the target registry prefix and remove SHA |
| 57 | + local -r dst_img="${TARGET_REGISTRY}/${src_img}" |
| 58 | + local -r dst_img_no_tag="${TARGET_REGISTRY}/${src_img%%[@:]*}" |
| 59 | + # Run the image upload |
| 60 | + echo "Uploading '${src_img}' to '${dst_img}'" |
| 61 | + skopeo copy --all --quiet \ |
| 62 | + --preserve-digests \ |
| 63 | + --authfile "${IMAGE_PULL_FILE}" \ |
| 64 | + dir://"${IMAGE_LOCAL_DIR}/${src_img}" docker://"${dst_img}" |
74 | 65 | done < <(find . -type f -name manifest.json -printf '%P\n') |
75 | 66 | popd >/dev/null |
76 | 67 | ---- |
0 commit comments