Skip to content

Commit

Permalink
fix(docker): add tags for all push registries to built containers
Browse files Browse the repository at this point in the history
  • Loading branch information
malept committed Jan 18, 2025
1 parent 1ff9c81 commit a27441d
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 5 deletions.
10 changes: 6 additions & 4 deletions shell/lib/docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,12 @@ docker_buildx_args() {
tags+=("$image")
if [[ -n $arch ]]; then
local remoteImageName
local pullRegistry
pullRegistry="$(get_docker_pull_registry)"
remoteImageName="$(determine_remote_image_name "$appName" "$pullRegistry" "$image")"
tags+=("$remoteImageName:latest-$arch" "$remoteImageName:$version-$arch")
local pushRegistries
pushRegistries="$(get_docker_push_registries)"
for pushRegistry in $pushRegistries; do
remoteImageName="$(determine_remote_image_name "$appName" "$pushRegistry" "$image")"
tags+=("$remoteImageName:latest-$arch" "$remoteImageName:$CIRCLE_TAG-$arch")
done
fi
fi
for tag in "${tags[@]}"; do
Expand Down
31 changes: 30 additions & 1 deletion shell/lib/docker_test.bats
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,42 @@ EOF
}

@test "docker_buildx_args adds tags when CIRCLE_TAG exists and arch specified" {
cat >"$BOXPATH" <<EOF
config:
docker:
imagePushRegistries:
- example.com
EOF

cat >"$YAML_FILE" <<EOF
myservice:
EOF

CIRCLE_TAG="0.10.0" MANIFEST="$YAML_FILE" run docker_buildx_args "myservice" "0.10.0" "myimage" "foo/Dockerfile" "arm64"
assert_output --partial " --tag myimage"
assert_output --partial " --tag /myservice/myimage:latest-arm64"
assert_output --partial " --tag example.com/myservice/myimage:latest-arm64"
}

@test "docker_buildx_args with BOX_DOCKER_PUSH_IMAGE_REGISTRIES" {
cat >"$BOXPATH" <<EOF
config:
docker:
imagePushRegistries:
- example.com
EOF
cat >"$YAML_FILE" <<EOF
myservice:
EOF

BOX_DOCKER_PUSH_IMAGE_REGISTRIES="example.com/box1 example.com/box2" \
CIRCLE_TAG="0.10.0" \
MANIFEST="$YAML_FILE" \
run docker_buildx_args "myservice" "0.10.0" "myimage" "foo/Dockerfile" "arm64"

assert_output --partial " --tag example.com/box1/myservice/myimage:latest-arm64"
assert_output --partial " --tag example.com/box1/myservice/myimage:0.10.0-arm64"
assert_output --partial " --tag example.com/box2/myservice/myimage:latest-arm64"
assert_output --partial " --tag example.com/box2/myservice/myimage:0.10.0-arm64"
}

@test "get_docker_push_registries from box config" {
Expand Down

0 comments on commit a27441d

Please sign in to comment.