Skip to content

Commit a32133a

Browse files
tomassrnkaclaude
andauthored
fix: default BUILD_ARCH to amd64 instead of host architecture (#2295)
BUILD_ARCH defaulting to $(shell go env GOARCH) causes Apple Silicon Macs to produce arm64 binaries when deploying to amd64 dev/staging clusters. Default to amd64 since that's the current deployment target. Override with BUILD_ARCH=arm64 for ARM64 builds (in .env.local or on the command line). Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 2b29315 commit a32133a

File tree

5 files changed

+14
-11
lines changed

5 files changed

+14
-11
lines changed

packages/client-proxy/Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ ARG GOLANG_VERSION=1.25.4
22
ARG ALPINE_VERSION=3.22
33

44
FROM golang:${GOLANG_VERSION}-alpine${ALPINE_VERSION} AS builder
5+
ARG TARGETARCH
56

67
RUN apk add --no-cache make
78

@@ -32,7 +33,8 @@ COPY ./client-proxy/Makefile ./client-proxy/Makefile
3233
WORKDIR /build/client-proxy
3334

3435
ARG COMMIT_SHA
35-
RUN --mount=type=cache,target=/root/.cache/go-build make build COMMIT_SHA=${COMMIT_SHA}
36+
# Use Docker's TARGETARCH so GOARCH matches the container platform.
37+
RUN --mount=type=cache,target=/root/.cache/go-build make build COMMIT_SHA=${COMMIT_SHA} BUILD_ARCH=${TARGETARCH}
3638
RUN chmod +x /build/client-proxy/bin/client-proxy
3739

3840
FROM alpine:${ALPINE_VERSION}

packages/client-proxy/Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ PREFIX := $(strip $(subst ",,$(PREFIX)))
66
HOSTNAME := $(shell hostname 2> /dev/null || hostnamectl hostname 2> /dev/null)
77
$(if $(HOSTNAME),,$(error Failed to determine hostname: both 'hostname' and 'hostnamectl' failed))
88

9-
# Architecture for builds. Defaults to local arch; override for cross-compilation
10-
# (e.g., BUILD_ARCH=amd64 make build-and-upload from an ARM64 host).
11-
BUILD_ARCH ?= $(shell go env GOARCH)
9+
# Architecture for builds. Defaults to amd64; override for ARM64 builds.
10+
# (e.g., BUILD_ARCH=arm64 make build-and-upload)
11+
BUILD_ARCH ?= amd64
1212
# Docker platform string. Override for multi-arch builds:
1313
# BUILD_PLATFORM=linux/amd64,linux/arm64 make build-and-upload
1414
BUILD_PLATFORM ?= linux/$(BUILD_ARCH)

packages/envd/Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ LDFLAGS=-ldflags "-X=main.commitSHA=$(BUILD)"
77
AWS_BUCKET_PREFIX ?= $(PREFIX)$(AWS_ACCOUNT_ID)-
88
GCP_BUCKET_PREFIX ?= $(GCP_PROJECT_ID)-
99

10-
# Architecture for builds. Defaults to local arch; override for cross-compilation
11-
# (e.g., BUILD_ARCH=amd64 make build from an ARM64 host).
12-
BUILD_ARCH ?= $(shell go env GOARCH)
10+
# Architecture for builds. Defaults to amd64; override for ARM64 builds.
11+
# (e.g., BUILD_ARCH=arm64 make build-local)
12+
BUILD_ARCH ?= amd64
1313
# Docker platform string. Override for cross-platform builds:
1414
# BUILD_PLATFORM=linux/arm64 make start-docker
1515
BUILD_PLATFORM ?= linux/$(BUILD_ARCH)

packages/orchestrator/Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ RUN ./orchestrator/scripts/fetch-busybox.sh "${BUSYBOX_VERSION}" "${TARGETARCH}"
4444
WORKDIR /build/orchestrator
4545

4646
ARG COMMIT_SHA
47-
RUN --mount=type=cache,target=/root/.cache/go-build make build-local COMMIT_SHA=${COMMIT_SHA}
47+
# Use Docker's TARGETARCH (set by --platform) so GOARCH matches the container platform.
48+
RUN --mount=type=cache,target=/root/.cache/go-build make build-local COMMIT_SHA=${COMMIT_SHA} BUILD_ARCH=${TARGETARCH}
4849

4950
FROM scratch
5051

packages/orchestrator/Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ GCP_BUCKET_PREFIX ?= $(GCP_PROJECT_ID)-
77
HOSTNAME := $(shell hostname 2> /dev/null || hostnamectl hostname 2> /dev/null)
88
$(if $(HOSTNAME),,$(error Failed to determine hostname: both 'hostname' and 'hostnamectl' failed))
99

10-
# Architecture for builds. Defaults to local arch; override for cross-compilation
11-
# (e.g., BUILD_ARCH=amd64 make build from an ARM64 host).
12-
BUILD_ARCH ?= $(shell go env GOARCH)
10+
# Architecture for builds. Defaults to amd64; override for ARM64 builds.
11+
# (e.g., BUILD_ARCH=arm64 make build-local)
12+
BUILD_ARCH ?= amd64
1313
# Docker platform string. Override for cross-platform builds:
1414
# BUILD_PLATFORM=linux/arm64 make build
1515
BUILD_PLATFORM ?= linux/$(BUILD_ARCH)

0 commit comments

Comments
 (0)