Skip to content

Commit

Permalink
chore: speed up image sync (#2903)
Browse files Browse the repository at this point in the history
  • Loading branch information
anda-ren authored Oct 25, 2023
1 parent a616b14 commit 52368b4
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions scripts/publish/image_sync.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ fi
export source_registry=${source_registry:="ghcr.io"}
export source_repo_name=${source_repo_name:="star-whale"}
export target_registry=${target_registry:="homepage-bj.intra.starwhale.ai:5000"}
export target_registry_read_only=${target_registry_read_only:="docker-registry.starwhale.cn"}
target_repo_name1=star-whale
target_repo_name2=starwhaleai

Expand All @@ -44,10 +45,14 @@ function get_tags() {
# start to sync images
declare -a starwhale_images=("server" "base" "cuda" "dataset_builder" "runtime-dockerizing")
for image in "${starwhale_images[@]}"; do
tags=$(get_tags "$image")
# if the image has already synced, regctl would skip it.
for tag in $tags; do
copy_image "$source_repo_name/$image:$tag" "$target_repo_name1/$image:$tag"
copy_image "$source_repo_name/$image:$tag" "$target_repo_name2/$image:$tag"
done
source_repo_tags=$(./regctl tag -v error ls "$source_registry"/star-whale/"$image")
target_repo_tags1=$(./regctl tag -v error ls "$target_registry_read_only"/"$target_repo_name1"/"$image")
target_repo_tags2=$(./regctl tag -v error ls "$target_registry_read_only"/"$target_repo_name2"/"$image")

while IFS= read -r line; do
copy_image "$source_repo_name/$image:$line" "$target_repo_name2/$image:$line"
done < <(comm -23 <(sort <<< "$source_repo_tags") <(sort <<< "$target_repo_tags1"))
while IFS= read -r line; do
copy_image "$source_repo_name/$image:$line" "$target_repo_name2/$image:$line"
done < <(comm -23 <(sort <<< "$source_repo_tags") <(sort <<< "$target_repo_tags2"))
done

0 comments on commit 52368b4

Please sign in to comment.