From f733d91ad07da31a39fbfbe64edd5ce6d83ab06b Mon Sep 17 00:00:00 2001 From: Sertac Ozercan Date: Fri, 8 Nov 2024 23:24:30 +0000 Subject: [PATCH 1/2] ci: linux/amd64 and linux/arm64 multi platform image Signed-off-by: Sertac Ozercan --- kustomize.Dockerfile | 5 +++-- releasing/cloudbuild_kustomize_image.yaml | 2 ++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/kustomize.Dockerfile b/kustomize.Dockerfile index 66f59ee926..48fab6b0bc 100644 --- a/kustomize.Dockerfile +++ b/kustomize.Dockerfile @@ -1,15 +1,16 @@ # Copyright 2022 The Kubernetes Authors. # SPDX-License-Identifier: Apache-2.0 +ARG TARGETARCH TARGETOS # build -FROM public.ecr.aws/docker/library/golang:1.22.7-bullseye as builder +FROM --platform=${BUILDPLATFORM} public.ecr.aws/docker/library/golang:1.22.7-bullseye as builder ARG VERSION ARG COMMIT ARG DATE RUN mkdir /build ADD . /build/ WORKDIR /build/kustomize -RUN CGO_ENABLED=0 GO111MODULE=on go build \ +RUN CGO_ENABLED=0 GO111MODULE=on GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build \ -ldflags="-s -X sigs.k8s.io/kustomize/api/provenance.version=${VERSION} \ -X sigs.k8s.io/kustomize/api/provenance.buildDate=${DATE}" diff --git a/releasing/cloudbuild_kustomize_image.yaml b/releasing/cloudbuild_kustomize_image.yaml index 605b292171..3aa325f54a 100644 --- a/releasing/cloudbuild_kustomize_image.yaml +++ b/releasing/cloudbuild_kustomize_image.yaml @@ -29,6 +29,8 @@ steps: COMMIT=$(git rev-parse HEAD) --build-arg DATE=$(date -u +%FT%TZ) + --platform + linux/amd64,linux/arm64 . images: From 4ab87f41d48bf368eab13e6f0221bb3f46c06c04 Mon Sep 17 00:00:00 2001 From: Sertac Ozercan Date: Wed, 13 Nov 2024 18:54:45 +0000 Subject: [PATCH 2/2] buildx Signed-off-by: Sertac Ozercan --- releasing/cloudbuild_kustomize_image.yaml | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/releasing/cloudbuild_kustomize_image.yaml b/releasing/cloudbuild_kustomize_image.yaml index 3aa325f54a..b02725a524 100644 --- a/releasing/cloudbuild_kustomize_image.yaml +++ b/releasing/cloudbuild_kustomize_image.yaml @@ -9,13 +9,26 @@ steps: - "PROJECT_ID=$PROJECT_ID" - "_GIT_TAG=$_GIT_TAG" - "_PULL_BASE_REF=$_PULL_BASE_REF" -# We need to use bash to configure the build date and version properly. - name: "gcr.io/cloud-builders/docker" entrypoint: /bin/bash args: - -c - > docker + buildx + create + --name + builder + --use + --bootstrap + # We need to use bash to configure the build date and version properly. + - name: "gcr.io/cloud-builders/docker" + entrypoint: /bin/bash + args: + - -c + - > + docker + buildx build -t gcr.io/$PROJECT_ID/kustomize:${_GIT_TAG}