-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c99d2b9
commit 6f57a03
Showing
1 changed file
with
34 additions
and
28 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,32 +1,38 @@ | ||
#!/bin/bash | ||
|
||
while read -r image; do | ||
# 检查是否有 / | ||
if [[ $image == *"/*"* ]]; then | ||
# 截取 / 后的值 | ||
repository=$(basename "$image") | ||
tag=$(echo "$image" | cut -d : -f 2) | ||
new_image="registry.cn-hangzhou.aliyuncs.com/wct_registry/$repository:$tag" | ||
else | ||
# 如果没有 /,则直接使用原名称作为新的repository | ||
new_image="registry.cn-hangzhou.aliyuncs.com/wct_registry/$image" | ||
fi | ||
|
||
# 拉取镜像,重新标记镜像,推送 | ||
docker pull --platform=linux/arm64 "$image" | ||
docker tag "$image" "$new_image-arm64" | ||
docker push "$new_image-arm64" | ||
|
||
# 拉取镜像,重新标记镜像,推送 | ||
docker pull --platform=linux/amd64 "$image" | ||
docker tag "$image" "$new_image-amd64" | ||
docker push "$new_image-amd64" | ||
function DockerImages() { | ||
while read -r image; do | ||
# 检查是否有 / | ||
if [[ $image == *"/*"* ]]; then | ||
# 截取 / 后的值 | ||
repository=$(basename "$image") | ||
tag=$(echo "$image" | cut -d : -f 2) | ||
new_image="registry.cn-hangzhou.aliyuncs.com/wct_registry/$repository:$tag" | ||
else | ||
# 如果没有 /,则直接使用原名称作为新的repository | ||
new_image="registry.cn-hangzhou.aliyuncs.com/wct_registry/$image" | ||
fi | ||
|
||
# 拉取镜像,重新标记镜像,推送 | ||
docker pull --platform=linux/arm64 "$image" | ||
docker tag "$image" "$new_image-arm64" | ||
docker push "$new_image-arm64" | ||
|
||
# 拉取镜像,重新标记镜像,推送 | ||
docker pull --platform=linux/amd64 "$image" | ||
docker tag "$image" "$new_image-amd64" | ||
docker push "$new_image-amd64" | ||
|
||
#创建manifest | ||
docker manifest create ${new_image} \ | ||
${new_image}-amd64 \ | ||
${new_image}-arm64 --amend | ||
|
||
docker manifest push ${new_image} | ||
|
||
done < images.txt | ||
} | ||
|
||
#创建manifest | ||
docker manifest create ${new_image} \ | ||
${new_image}-amd64 \ | ||
${new_image}-arm64 --amend | ||
DockerImages | ||
|
||
docker manifest push ${new_image} | ||
|
||
done < images.txt | ||
exit 0 |