Skip to content

Commit 911760b

Browse files
tomassrnkae2bclaude
authored
chore: parameterize BUILD_ARCH/BUILD_PLATFORM in Makefiles (#2257)
* 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) <noreply@anthropic.com> * 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) <noreply@anthropic.com> * 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) <noreply@anthropic.com> --------- Co-authored-by: e2b <e2b@Onsites-MacBook-Pro.local> Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 26a0e91 commit 911760b

File tree

3 files changed

+32
-11
lines changed

3 files changed

+32
-11
lines changed

packages/client-proxy/Makefile

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@ 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)
12+
# Docker platform string. Override for multi-arch builds:
13+
# BUILD_PLATFORM=linux/amd64,linux/arm64 make build-and-upload
14+
BUILD_PLATFORM ?= linux/$(BUILD_ARCH)
15+
916
ifeq ($(PROVIDER),aws)
1017
IMAGE_REGISTRY := $(AWS_ACCOUNT_ID).dkr.ecr.$(AWS_REGION).amazonaws.com/$(PREFIX)core/client-proxy
1118
else
@@ -16,7 +23,7 @@ endif
1623
build:
1724
# Allow for passing commit sha directly for docker builds
1825
$(eval COMMIT_SHA ?= $(shell git rev-parse --short HEAD))
19-
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o bin/client-proxy -ldflags "-X=main.commitSHA=$(COMMIT_SHA)" .
26+
CGO_ENABLED=0 GOOS=linux GOARCH=$(BUILD_ARCH) go build -o bin/client-proxy -ldflags "-X=main.commitSHA=$(COMMIT_SHA)" .
2027

2128
.PHONY: build-debug
2229
build-debug:
@@ -26,7 +33,7 @@ build-debug:
2633
.PHONY: build-and-upload
2734
build-and-upload:
2835
$(eval COMMIT_SHA := $(shell git rev-parse --short HEAD))
29-
@docker buildx build --platform linux/amd64 --tag $(IMAGE_REGISTRY) --push --build-arg COMMIT_SHA="$(COMMIT_SHA)" -f ./Dockerfile ..
36+
@docker buildx build --platform $(BUILD_PLATFORM) --tag $(IMAGE_REGISTRY) --push --build-arg COMMIT_SHA="$(COMMIT_SHA)" -f ./Dockerfile ..
3037

3138
.PHONY: run
3239
run:

packages/envd/Makefile

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@ 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)
13+
# Docker platform string. Override for cross-platform builds:
14+
# BUILD_PLATFORM=linux/arm64 make start-docker
15+
BUILD_PLATFORM ?= linux/$(BUILD_ARCH)
16+
1017
.PHONY: init
1118
init:
1219
brew install protobuf
@@ -20,17 +27,17 @@ else
2027
endif
2128

2229
build:
23-
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -o bin/envd ${LDFLAGS}
30+
CGO_ENABLED=0 GOOS=linux GOARCH=$(BUILD_ARCH) go build -a -o bin/envd ${LDFLAGS}
2431

2532
build-debug:
2633
CGO_ENABLED=1 go build -race -gcflags=all="-N -l" -o bin/debug/envd ${LDFLAGS}
2734

2835
start-docker:
2936
make build
30-
DOCKER_BUILDKIT=1 docker build --platform linux/amd64 -t envd-debug . -f debug.Dockerfile
37+
DOCKER_BUILDKIT=1 docker build --platform $(BUILD_PLATFORM) -t envd-debug . -f debug.Dockerfile
3138
docker run \
3239
--name envd \
33-
--platform linux/amd64 \
40+
--platform $(BUILD_PLATFORM) \
3441
-p 49983:49983 \
3542
-p 2345:2345 \
3643
-p 9999:9999 \

packages/orchestrator/Makefile

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@ 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)
13+
# Docker platform string. Override for cross-platform builds:
14+
# BUILD_PLATFORM=linux/arm64 make build
15+
BUILD_PLATFORM ?= linux/$(BUILD_ARCH)
16+
1017
.PHONY: init
1118
init:
1219
brew install protobuf
@@ -18,18 +25,18 @@ generate:
1825
.PHONY: build
1926
build:
2027
$(eval COMMIT_SHA := $(shell git rev-parse --short HEAD))
21-
@docker build --platform linux/amd64 --output=bin --build-arg COMMIT_SHA="$(COMMIT_SHA)" -f ./Dockerfile ..
28+
@docker build --platform $(BUILD_PLATFORM) --output=bin --build-arg COMMIT_SHA="$(COMMIT_SHA)" -f ./Dockerfile ..
2229

2330
.PHONY: build-local
2431
build-local:
2532
# Allow for passing commit sha directly for docker builds
2633
$(eval COMMIT_SHA ?= $(shell git rev-parse --short HEAD))
27-
CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build -o bin/orchestrator -ldflags "-X=main.commitSHA=$(COMMIT_SHA)" .
28-
CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build -o bin/clean-nfs-cache -ldflags "-X=main.commitSHA=$(COMMIT_SHA)" ./cmd/clean-nfs-cache
34+
CGO_ENABLED=1 GOOS=linux GOARCH=$(BUILD_ARCH) go build -o bin/orchestrator -ldflags "-X=main.commitSHA=$(COMMIT_SHA)" .
35+
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
2936

3037
.PHONY: build-debug
3138
build-debug:
32-
CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build -race -gcflags=all="-N -l" -o bin/orchestrator .
39+
CGO_ENABLED=1 GOOS=linux GOARCH=$(BUILD_ARCH) go build -race -gcflags=all="-N -l" -o bin/orchestrator .
3340

3441
.PHONY: run-debug
3542
run-debug:
@@ -100,12 +107,12 @@ test:
100107

101108
.PHONY: test-docker
102109
test-docker:
103-
@echo "Running orchestrator tests in Docker (AMD64 Linux)..."
110+
@echo "Running orchestrator tests in Docker ($(BUILD_PLATFORM))..."
104111
@rm -rf .shared/
105112
@cp -r ../shared .shared/
106113
@rm -rf .clickhouse/
107114
@cp -r ../clickhouse .clickhouse/
108-
@docker build --platform linux/amd64 -f test.Dockerfile --no-cache-filter runner --progress=plain -t orchestrator-test .
115+
@docker build --platform $(BUILD_PLATFORM) -f test.Dockerfile --no-cache-filter runner --progress=plain -t orchestrator-test .
109116
@rm -rf .shared/
110117
@rm -rf .clickhouse/
111118
@echo "Done"

0 commit comments

Comments
 (0)