From ff8ed13fa090a47f2c411598e96d8104dbcf1bd2 Mon Sep 17 00:00:00 2001 From: e2b Date: Sun, 29 Mar 2026 17:10:24 +0200 Subject: [PATCH 1/3] chore: parameterize BUILD_ARCH/BUILD_PLATFORM in Makefiles Replace hardcoded amd64/linux/amd64 with BUILD_ARCH and BUILD_PLATFORM variables across all service Makefiles. Defaults to host architecture via `go env GOARCH`, preserving existing behavior. Enables cross-compilation by setting BUILD_ARCH=arm64 or multi-arch Docker builds via BUILD_PLATFORM=linux/amd64,linux/arm64. Co-Authored-By: Claude Opus 4.6 (1M context) --- packages/api/Makefile | 7 +++++++ packages/client-proxy/Makefile | 11 +++++++++-- packages/envd/Makefile | 13 ++++++++++--- packages/orchestrator/Makefile | 17 ++++++++++++----- 4 files changed, 38 insertions(+), 10 deletions(-) diff --git a/packages/api/Makefile b/packages/api/Makefile index 5c580ee5cd..0ba964f404 100644 --- a/packages/api/Makefile +++ b/packages/api/Makefile @@ -6,6 +6,13 @@ PREFIX := $(strip $(subst ",,$(PREFIX))) HOSTNAME := $(shell hostname 2> /dev/null || hostnamectl hostname 2> /dev/null) $(if $(HOSTNAME),,$(error Failed to determine hostname: both 'hostname' and 'hostnamectl' failed)) +# Architecture for builds. Defaults to local arch; override for cross-compilation +# (e.g., BUILD_ARCH=amd64 make build-and-upload from an ARM64 host). +BUILD_ARCH ?= $(shell go env GOARCH) +# Docker platform string. Override for multi-arch builds: +# BUILD_PLATFORM=linux/amd64,linux/arm64 make build-and-upload +BUILD_PLATFORM ?= linux/$(BUILD_ARCH) + expectedMigration := $(shell ./../../scripts/get-latest-migration.sh) ifeq ($(PROVIDER),aws) diff --git a/packages/client-proxy/Makefile b/packages/client-proxy/Makefile index 383ea0fc9f..36e0e3d4b1 100644 --- a/packages/client-proxy/Makefile +++ b/packages/client-proxy/Makefile @@ -6,6 +6,13 @@ PREFIX := $(strip $(subst ",,$(PREFIX))) HOSTNAME := $(shell hostname 2> /dev/null || hostnamectl hostname 2> /dev/null) $(if $(HOSTNAME),,$(error Failed to determine hostname: both 'hostname' and 'hostnamectl' failed)) +# Architecture for builds. Defaults to local arch; override for cross-compilation +# (e.g., BUILD_ARCH=amd64 make build-and-upload from an ARM64 host). +BUILD_ARCH ?= $(shell go env GOARCH) +# Docker platform string. Override for multi-arch builds: +# BUILD_PLATFORM=linux/amd64,linux/arm64 make build-and-upload +BUILD_PLATFORM ?= linux/$(BUILD_ARCH) + ifeq ($(PROVIDER),aws) IMAGE_REGISTRY := $(AWS_ACCOUNT_ID).dkr.ecr.$(AWS_REGION).amazonaws.com/$(PREFIX)core/client-proxy else @@ -16,7 +23,7 @@ endif build: # Allow for passing commit sha directly for docker builds $(eval COMMIT_SHA ?= $(shell git rev-parse --short HEAD)) - CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o bin/client-proxy -ldflags "-X=main.commitSHA=$(COMMIT_SHA)" . + CGO_ENABLED=0 GOOS=linux GOARCH=$(BUILD_ARCH) go build -o bin/client-proxy -ldflags "-X=main.commitSHA=$(COMMIT_SHA)" . .PHONY: build-debug build-debug: @@ -26,7 +33,7 @@ build-debug: .PHONY: build-and-upload build-and-upload: $(eval COMMIT_SHA := $(shell git rev-parse --short HEAD)) - @docker buildx build --platform linux/amd64 --tag $(IMAGE_REGISTRY) --push --build-arg COMMIT_SHA="$(COMMIT_SHA)" -f ./Dockerfile .. + @docker buildx build --platform $(BUILD_PLATFORM) --tag $(IMAGE_REGISTRY) --push --build-arg COMMIT_SHA="$(COMMIT_SHA)" -f ./Dockerfile .. .PHONY: run run: diff --git a/packages/envd/Makefile b/packages/envd/Makefile index f073d37ae7..54396a564b 100644 --- a/packages/envd/Makefile +++ b/packages/envd/Makefile @@ -7,6 +7,13 @@ LDFLAGS=-ldflags "-X=main.commitSHA=$(BUILD)" AWS_BUCKET_PREFIX ?= $(PREFIX)$(AWS_ACCOUNT_ID)- GCP_BUCKET_PREFIX ?= $(GCP_PROJECT_ID)- +# Architecture for builds. Defaults to local arch; override for cross-compilation +# (e.g., BUILD_ARCH=amd64 make build from an ARM64 host). +BUILD_ARCH ?= $(shell go env GOARCH) +# Docker platform string. Override for multi-arch builds: +# BUILD_PLATFORM=linux/amd64,linux/arm64 make start-docker +BUILD_PLATFORM ?= linux/$(BUILD_ARCH) + .PHONY: init init: brew install protobuf @@ -20,17 +27,17 @@ else endif build: - CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -o bin/envd ${LDFLAGS} + CGO_ENABLED=0 GOOS=linux GOARCH=$(BUILD_ARCH) go build -a -o bin/envd ${LDFLAGS} build-debug: CGO_ENABLED=1 go build -race -gcflags=all="-N -l" -o bin/debug/envd ${LDFLAGS} start-docker: make build - DOCKER_BUILDKIT=1 docker build --platform linux/amd64 -t envd-debug . -f debug.Dockerfile + DOCKER_BUILDKIT=1 docker build --platform $(BUILD_PLATFORM) -t envd-debug . -f debug.Dockerfile docker run \ --name envd \ - --platform linux/amd64 \ + --platform $(BUILD_PLATFORM) \ -p 49983:49983 \ -p 2345:2345 \ -p 9999:9999 \ diff --git a/packages/orchestrator/Makefile b/packages/orchestrator/Makefile index 94da7d669b..d8a5eac727 100644 --- a/packages/orchestrator/Makefile +++ b/packages/orchestrator/Makefile @@ -7,6 +7,13 @@ GCP_BUCKET_PREFIX ?= $(GCP_PROJECT_ID)- HOSTNAME := $(shell hostname 2> /dev/null || hostnamectl hostname 2> /dev/null) $(if $(HOSTNAME),,$(error Failed to determine hostname: both 'hostname' and 'hostnamectl' failed)) +# Architecture for builds. Defaults to local arch; override for cross-compilation +# (e.g., BUILD_ARCH=amd64 make build from an ARM64 host). +BUILD_ARCH ?= $(shell go env GOARCH) +# Docker platform string. Override for multi-arch builds: +# BUILD_PLATFORM=linux/amd64,linux/arm64 make build +BUILD_PLATFORM ?= linux/$(BUILD_ARCH) + .PHONY: init init: brew install protobuf @@ -18,18 +25,18 @@ generate: .PHONY: build build: $(eval COMMIT_SHA := $(shell git rev-parse --short HEAD)) - @docker build --platform linux/amd64 --output=bin --build-arg COMMIT_SHA="$(COMMIT_SHA)" -f ./Dockerfile .. + @docker build --platform $(BUILD_PLATFORM) --output=bin --build-arg COMMIT_SHA="$(COMMIT_SHA)" -f ./Dockerfile .. .PHONY: build-local build-local: # Allow for passing commit sha directly for docker builds $(eval COMMIT_SHA ?= $(shell git rev-parse --short HEAD)) - CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build -o bin/orchestrator -ldflags "-X=main.commitSHA=$(COMMIT_SHA)" . - CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build -o bin/clean-nfs-cache -ldflags "-X=main.commitSHA=$(COMMIT_SHA)" ./cmd/clean-nfs-cache + CGO_ENABLED=1 GOOS=linux GOARCH=$(BUILD_ARCH) go build -o bin/orchestrator -ldflags "-X=main.commitSHA=$(COMMIT_SHA)" . + CGO_ENABLED=1 GOOS=linux GOARCH=$(BUILD_ARCH) go build -o bin/clean-nfs-cache -ldflags "-X=main.commitSHA=$(COMMIT_SHA)" ./cmd/clean-nfs-cache .PHONY: build-debug build-debug: - CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build -race -gcflags=all="-N -l" -o bin/orchestrator . + CGO_ENABLED=1 GOOS=linux GOARCH=$(BUILD_ARCH) go build -race -gcflags=all="-N -l" -o bin/orchestrator . .PHONY: run-debug run-debug: @@ -105,7 +112,7 @@ test-docker: @cp -r ../shared .shared/ @rm -rf .clickhouse/ @cp -r ../clickhouse .clickhouse/ - @docker build --platform linux/amd64 -f test.Dockerfile --no-cache-filter runner --progress=plain -t orchestrator-test . + @docker build --platform $(BUILD_PLATFORM) -f test.Dockerfile --no-cache-filter runner --progress=plain -t orchestrator-test . @rm -rf .shared/ @rm -rf .clickhouse/ @echo "Done" From d5173be7fa3bcc0b91082ccfc6d91abb26a689e2 Mon Sep 17 00:00:00 2001 From: e2b Date: Sun, 29 Mar 2026 17:17:53 +0200 Subject: [PATCH 2/3] fix: remove unused BUILD_ARCH from api Makefile, fix multi-arch comments - Remove BUILD_ARCH/BUILD_PLATFORM from api Makefile (uses docker-bake.hcl) - Fix misleading multi-arch BUILD_PLATFORM examples in envd and orchestrator Makefiles (these use plain docker build, not buildx) Co-Authored-By: Claude Opus 4.6 (1M context) --- packages/api/Makefile | 7 ------- packages/envd/Makefile | 4 ++-- packages/orchestrator/Makefile | 4 ++-- 3 files changed, 4 insertions(+), 11 deletions(-) diff --git a/packages/api/Makefile b/packages/api/Makefile index 0ba964f404..5c580ee5cd 100644 --- a/packages/api/Makefile +++ b/packages/api/Makefile @@ -6,13 +6,6 @@ PREFIX := $(strip $(subst ",,$(PREFIX))) HOSTNAME := $(shell hostname 2> /dev/null || hostnamectl hostname 2> /dev/null) $(if $(HOSTNAME),,$(error Failed to determine hostname: both 'hostname' and 'hostnamectl' failed)) -# Architecture for builds. Defaults to local arch; override for cross-compilation -# (e.g., BUILD_ARCH=amd64 make build-and-upload from an ARM64 host). -BUILD_ARCH ?= $(shell go env GOARCH) -# Docker platform string. Override for multi-arch builds: -# BUILD_PLATFORM=linux/amd64,linux/arm64 make build-and-upload -BUILD_PLATFORM ?= linux/$(BUILD_ARCH) - expectedMigration := $(shell ./../../scripts/get-latest-migration.sh) ifeq ($(PROVIDER),aws) diff --git a/packages/envd/Makefile b/packages/envd/Makefile index 54396a564b..b54f648785 100644 --- a/packages/envd/Makefile +++ b/packages/envd/Makefile @@ -10,8 +10,8 @@ GCP_BUCKET_PREFIX ?= $(GCP_PROJECT_ID)- # Architecture for builds. Defaults to local arch; override for cross-compilation # (e.g., BUILD_ARCH=amd64 make build from an ARM64 host). BUILD_ARCH ?= $(shell go env GOARCH) -# Docker platform string. Override for multi-arch builds: -# BUILD_PLATFORM=linux/amd64,linux/arm64 make start-docker +# Docker platform string. Override for cross-platform builds: +# BUILD_PLATFORM=linux/arm64 make start-docker BUILD_PLATFORM ?= linux/$(BUILD_ARCH) .PHONY: init diff --git a/packages/orchestrator/Makefile b/packages/orchestrator/Makefile index d8a5eac727..665bdd6497 100644 --- a/packages/orchestrator/Makefile +++ b/packages/orchestrator/Makefile @@ -10,8 +10,8 @@ $(if $(HOSTNAME),,$(error Failed to determine hostname: both 'hostname' and 'hos # Architecture for builds. Defaults to local arch; override for cross-compilation # (e.g., BUILD_ARCH=amd64 make build from an ARM64 host). BUILD_ARCH ?= $(shell go env GOARCH) -# Docker platform string. Override for multi-arch builds: -# BUILD_PLATFORM=linux/amd64,linux/arm64 make build +# Docker platform string. Override for cross-platform builds: +# BUILD_PLATFORM=linux/arm64 make build BUILD_PLATFORM ?= linux/$(BUILD_ARCH) .PHONY: init From 7318e8f156bdc50ce2a163921ed3da5a2b94cea0 Mon Sep 17 00:00:00 2001 From: e2b Date: Sun, 29 Mar 2026 19:40:20 +0200 Subject: [PATCH 3/3] fix: use BUILD_PLATFORM in test-docker echo message Replace hardcoded 'AMD64 Linux' with $(BUILD_PLATFORM) so the log output reflects the actual platform being tested. Co-Authored-By: Claude Opus 4.6 (1M context) --- packages/orchestrator/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/orchestrator/Makefile b/packages/orchestrator/Makefile index 665bdd6497..5feb4af992 100644 --- a/packages/orchestrator/Makefile +++ b/packages/orchestrator/Makefile @@ -107,7 +107,7 @@ test: .PHONY: test-docker test-docker: - @echo "Running orchestrator tests in Docker (AMD64 Linux)..." + @echo "Running orchestrator tests in Docker ($(BUILD_PLATFORM))..." @rm -rf .shared/ @cp -r ../shared .shared/ @rm -rf .clickhouse/