diff --git a/src/cloud-api-adaptor/hack/build.sh b/src/cloud-api-adaptor/hack/build.sh index 29db58de3d..4932a7cd9b 100755 --- a/src/cloud-api-adaptor/hack/build.sh +++ b/src/cloud-api-adaptor/hack/build.sh @@ -34,12 +34,32 @@ function get_tag_string() { local tag_string="" for tag in ${tags/,/ };do - tag_string+=" -t ${registry}/${name}:${tag}" + tag_string+=" ${registry}/${name}:${tag}" done echo "$tag_string" } +# Add -t to each item of the tag list +function add_tflags() { + local tag_string="$1" + local tag_string_with_tflags="" + + for tag in ${tag_string}; do + tag_string_with_tflags+=" -t ${tag}" + done + + echo "$tag_string_with_tflags" +} + +function push_all_tags() { + local tag_string="$1" + for tag in ${tag_string}; do + echo "Pushing ${tag}" + docker push ${tag}; + done +} + function build_caa_payload_image() { pushd "${script_dir}/../../" @@ -51,6 +71,7 @@ function build_caa_payload_image() { tag_string="$(get_tag_string "$release_tags")" build_type=release fi + tag_string_with_tflags="$(add_tflags "$tag_string")" docker buildx build --platform "${supported_arches}" \ --build-arg RELEASE_BUILD="${release_build}" \ @@ -60,9 +81,12 @@ function build_caa_payload_image() { --build-arg YQ_VERSION="${YQ_VERSION}" \ --build-arg YQ_CHECKSUM="${YQ_CHECKSUM}" \ -f cloud-api-adaptor/Dockerfile \ - ${tag_string} \ - --push \ + ${tag_string_with_tflags} \ + --load \ . + + push_all_tags ${tag_string} + popd } @@ -72,7 +96,7 @@ function get_arch_specific_tag_string() { local tag_string="" for tag in ${tags/,/ };do - tag_string+=" -t ${registry}/${name}:${tag}-${arch}" + tag_string+=" ${registry}/${name}:${tag}-${arch}" done echo "$tag_string" @@ -96,6 +120,7 @@ function build_caa_payload_arch_specific() { tag_string="$(get_arch_specific_tag_string "$release_tags" "${arch}")" build_type=release fi + tag_string_with_tflags="$(add_tflags "$tag_string")" docker buildx build --platform "${supported_arches}" \ --build-arg RELEASE_BUILD="${release_build}" \ @@ -105,9 +130,10 @@ function build_caa_payload_arch_specific() { --build-arg YQ_VERSION="${YQ_VERSION}" \ --build-arg YQ_CHECKSUM="${YQ_CHECKSUM}" \ -f cloud-api-adaptor/Dockerfile \ - ${tag_string} \ + ${tag_string_with_tflags} \ --push \ . + popd }