From a666980ea4eafb3bcfba6b08960242ba9ba54dce Mon Sep 17 00:00:00 2001 From: Zoran Regvart Date: Wed, 22 Jan 2025 11:15:57 +0100 Subject: [PATCH] Build multiarch (amd64 and arm64) images Makes changes to the scripts in build/tools to build and push multiarch images. Now runs two `docker build` commands to build images for individual architectures, and an additional `docker manifest create` to create the multiarch manifest. When pushing `docker manifest push` is used instead of `docker push`. Signed-off-by: Zoran Regvart --- build/tools/builder.sh | 19 +++++++++++++++---- build/tools/releaser.sh | 4 ++-- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/build/tools/builder.sh b/build/tools/builder.sh index ec98fb7e5..54f9da10e 100755 --- a/build/tools/builder.sh +++ b/build/tools/builder.sh @@ -103,10 +103,21 @@ function build_cli_for_all() { function build_oci() { local tag_prefix=$1 - local os=linux - local arch=amd64 + local os=$2 + local arch=$3 - docker build --platform $os/$arch --build-arg NOOBAA_BIN_PATH=$(generate_full_bin_path $os $arch) -t $tag_prefix/noobaa-operator:$(get_noobaa_version) -f build/Dockerfile . + docker build --platform $os/$arch --build-arg NOOBAA_BIN_PATH=$(generate_full_bin_path $os $arch) -t $tag_prefix/noobaa-operator:${os}-${arch}-$(get_noobaa_version) -f build/Dockerfile . +} + +function build_oci_for_all() { + local repository=$1 + build_oci "${repository}" linux amd64 + build_oci "${repository}" linux arm64 + + local version=$(get_noobaa_version) + docker manifest create "${repository}/noobaa-operator:${version}" \ + --amend "${repository}/noobaa-operator:linux-amd64-${version}" \ + --amend "${repository}/noobaa-operator:linux-arm64-${version}" } function generate_krew_manifest() { @@ -209,7 +220,7 @@ function generate_operator_bundle() { function main() { check_deps "${dependencies[@]}" build_cli_for_all - build_oci ${OCI_ORG:-noobaa} + build_oci_for_all ${OCI_ORG:-noobaa} generate_krew_manifest generate_homebrew_formula generate_operator_bundle diff --git a/build/tools/releaser.sh b/build/tools/releaser.sh index 4de9a405f..315c5f3b1 100755 --- a/build/tools/releaser.sh +++ b/build/tools/releaser.sh @@ -201,13 +201,13 @@ function create_oci_release() { echo "$DOCKERHUB_TOKEN" | docker login -u "$DOCKERHUB_USERNAME" --password-stdin echo "Pushing the images to docker.io..." - docker push $docker_image + docker manifest push $docker_image echo "Logging in to quay.io..." echo "$QUAY_TOKEN" | docker login -u "$QUAY_USERNAME" --password-stdin quay.io echo "Pushing the images to quay.io..." - docker push $quay_image + docker manifest push $quay_image } function create_krew() {