From 53641a0c0c01c22dddd97c2e37bc170df26c4217 Mon Sep 17 00:00:00 2001 From: hime Date: Mon, 25 Nov 2024 22:10:07 +0000 Subject: [PATCH] Set GOARCH through TARGETPLATFORM to correctly build for ARM machines. --- Makefile | 6 +++--- cmd/csi_driver/Dockerfile | 2 +- cmd/metadata_prefetch/Dockerfile | 2 +- cmd/sidecar_mounter/Dockerfile | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index e74f3120..07552fa0 100755 --- a/Makefile +++ b/Makefile @@ -52,15 +52,15 @@ all: driver sidecar-mounter webhook metadata-prefetch driver: mkdir -p ${BINDIR} - CGO_ENABLED=0 GOOS=linux GOARCH=$(shell dpkg --print-architecture) go build -mod vendor -ldflags "${LDFLAGS}" -o ${BINDIR}/${DRIVER_BINARY} cmd/csi_driver/main.go + CGO_ENABLED=0 GOOS=linux go build -mod vendor -ldflags "${LDFLAGS}" -o ${BINDIR}/${DRIVER_BINARY} cmd/csi_driver/main.go sidecar-mounter: mkdir -p ${BINDIR} - CGO_ENABLED=0 GOOS=linux GOARCH=$(shell dpkg --print-architecture) go build -mod vendor -ldflags "${LDFLAGS}" -o ${BINDIR}/${SIDECAR_BINARY} cmd/sidecar_mounter/main.go + CGO_ENABLED=0 GOOS=linux go build -mod vendor -ldflags "${LDFLAGS}" -o ${BINDIR}/${SIDECAR_BINARY} cmd/sidecar_mounter/main.go metadata-prefetch: mkdir -p ${BINDIR} - CGO_ENABLED=0 GOOS=linux GOARCH=$(shell dpkg --print-architecture) go build -mod vendor -ldflags "${LDFLAGS}" -o ${BINDIR}/${PREFETCH_BINARY} cmd/metadata_prefetch/main.go + CGO_ENABLED=0 GOOS=linux go build -mod vendor -ldflags "${LDFLAGS}" -o ${BINDIR}/${PREFETCH_BINARY} cmd/metadata_prefetch/main.go webhook: mkdir -p ${BINDIR} diff --git a/cmd/csi_driver/Dockerfile b/cmd/csi_driver/Dockerfile index 8a8a3510..096d23be 100644 --- a/cmd/csi_driver/Dockerfile +++ b/cmd/csi_driver/Dockerfile @@ -20,7 +20,7 @@ ARG STAGINGVERSION WORKDIR /gcs-fuse-csi-driver ADD . . -RUN make driver BINDIR=/bin +RUN GOARCH=$(echo $TARGETPLATFORM | cut -f2 -d '/') make driver BINDIR=/bin # Start from Kubernetes Debian base. FROM gke.gcr.io/debian-base:bookworm-v1.0.2-gke.2 AS debian diff --git a/cmd/metadata_prefetch/Dockerfile b/cmd/metadata_prefetch/Dockerfile index 9e251ac9..4a65f585 100644 --- a/cmd/metadata_prefetch/Dockerfile +++ b/cmd/metadata_prefetch/Dockerfile @@ -20,7 +20,7 @@ ARG STAGINGVERSION WORKDIR /gcs-fuse-csi-driver ADD . . -RUN make metadata-prefetch BINDIR=/bin +RUN GOARCH=$(echo $TARGETPLATFORM | cut -f2 -d '/') make metadata-prefetch BINDIR=/bin # Start from Kubernetes Debian base. FROM gke.gcr.io/debian-base:bookworm-v1.0.2-gke.2 AS debian diff --git a/cmd/sidecar_mounter/Dockerfile b/cmd/sidecar_mounter/Dockerfile index 6f1b35c3..2e43793d 100644 --- a/cmd/sidecar_mounter/Dockerfile +++ b/cmd/sidecar_mounter/Dockerfile @@ -20,7 +20,7 @@ ARG STAGINGVERSION WORKDIR /gcs-fuse-csi-driver ADD . . -RUN make sidecar-mounter BINDIR=/bin +RUN GOARCH=$(echo $TARGETPLATFORM | cut -f2 -d '/') make sidecar-mounter BINDIR=/bin # go/gke-releasing-policies#base-images # We use `gcr.io/distroless/base` because it includes glibc.