Skip to content

Commit 0b5d74f

Browse files
e2bclaude
authored andcommitted
fix: make all Docker builds and Makefiles arch-aware
- nomad-nodepool-apm/Dockerfile: use TARGETARCH instead of hardcoded amd64 - api/docker-bake.hcl: parameterize platforms via BUILD_PLATFORM variable - clickhouse, dashboard-api, docker-reverse-proxy Makefiles: add standard BUILD_ARCH/BUILD_PLATFORM definitions, use $(BUILD_PLATFORM) consistently Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 62da00b commit 0b5d74f

File tree

5 files changed

+20
-6
lines changed

5 files changed

+20
-6
lines changed

packages/api/docker-bake.hcl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,18 @@ variable "EXPECTED_MIGRATION_TIMESTAMP" {
1010
default = ""
1111
}
1212

13+
variable "BUILD_PLATFORM" {
14+
default = "linux/amd64"
15+
}
16+
1317
group "default" {
1418
targets = ["api", "db-migrator"]
1519
}
1620

1721
target "api" {
1822
context = "."
1923
dockerfile = "api/Dockerfile"
20-
platforms = ["linux/amd64"]
24+
platforms = [BUILD_PLATFORM]
2125
tags = ["${REGISTRY_PREFIX}/api"]
2226
args = {
2327
COMMIT_SHA = COMMIT_SHA
@@ -28,6 +32,6 @@ target "api" {
2832
target "db-migrator" {
2933
context = "."
3034
dockerfile = "db/Dockerfile"
31-
platforms = ["linux/amd64"]
35+
platforms = [BUILD_PLATFORM]
3236
tags = ["${REGISTRY_PREFIX}/db-migrator"]
3337
}

packages/clickhouse/Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ ENV := $(shell cat ../../.last_used_env || echo "not-set")
22
-include ../../.env.${ENV}
33
PREFIX := $(strip $(subst ",,$(PREFIX)))
44

5+
BUILD_ARCH ?= $(shell go env GOARCH)
6+
BUILD_PLATFORM ?= linux/$(BUILD_ARCH)
7+
58
CLICKHOUSE_HOST ?= clickhouse
69

710
ifeq ($(PROVIDER),aws)
@@ -33,7 +36,7 @@ migrate-local:
3336

3437
.PHONY: build
3538
build:
36-
@docker build --platform linux/$(or $(BUILD_ARCH),$(shell go env GOARCH)) --tag "$(CLICKHOUSE_MIGRATOR_IMAGE)" .
39+
@docker build --platform $(BUILD_PLATFORM) --tag "$(CLICKHOUSE_MIGRATOR_IMAGE)" .
3740

3841
.PHONY: build-and-upload
3942
build-and-upload:build

packages/dashboard-api/Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ ENV := $(shell cat ../../.last_used_env || echo "not-set")
22
-include ../../.env.${ENV}
33
PREFIX := $(strip $(subst ",,$(PREFIX)))
44

5+
BUILD_ARCH ?= $(shell go env GOARCH)
6+
BUILD_PLATFORM ?= linux/$(BUILD_ARCH)
7+
58
expectedMigration := $(shell ./../../scripts/get-latest-migration.sh)
69

710
ifeq ($(PROVIDER),aws)
@@ -28,7 +31,7 @@ build:
2831
build-and-upload:
2932
$(eval COMMIT_SHA := $(shell git rev-parse --short HEAD))
3033
$(eval EXPECTED_MIGRATION_TIMESTAMP := $(expectedMigration))
31-
@ docker build --platform linux/$(or $(BUILD_ARCH),$(shell go env GOARCH)) --tag $(IMAGE_REGISTRY) --push --build-arg COMMIT_SHA="$(COMMIT_SHA)" --build-arg EXPECTED_MIGRATION_TIMESTAMP="$(EXPECTED_MIGRATION_TIMESTAMP)" -f ./Dockerfile ..
34+
@ docker build --platform $(BUILD_PLATFORM) --tag $(IMAGE_REGISTRY) --push --build-arg COMMIT_SHA="$(COMMIT_SHA)" --build-arg EXPECTED_MIGRATION_TIMESTAMP="$(EXPECTED_MIGRATION_TIMESTAMP)" -f ./Dockerfile ..
3235

3336
.PHONY: run
3437
run:

packages/docker-reverse-proxy/Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ ENV := $(shell cat ../../.last_used_env || echo "not-set")
22
-include ../../.env.${ENV}
33
PREFIX := $(strip $(subst ",,$(PREFIX)))
44

5+
BUILD_ARCH ?= $(shell go env GOARCH)
6+
BUILD_PLATFORM ?= linux/$(BUILD_ARCH)
7+
58
ifeq ($(PROVIDER),aws)
69
IMAGE_REGISTRY := $(AWS_ACCOUNT_ID).dkr.ecr.$(AWS_REGION).amazonaws.com/$(PREFIX)core/docker-reverse-proxy
710
else
@@ -21,7 +24,7 @@ build-debug:
2124
.PHONY: build-and-upload
2225
build-and-upload:
2326
$(eval COMMIT_SHA := $(shell git rev-parse --short HEAD))
24-
@docker buildx build --platform linux/$(or $(BUILD_ARCH),$(shell go env GOARCH)) --tag $(IMAGE_REGISTRY) --push --build-arg COMMIT_SHA="$(COMMIT_SHA)" -f ./Dockerfile ..
27+
@docker buildx build --platform $(BUILD_PLATFORM) --tag $(IMAGE_REGISTRY) --push --build-arg COMMIT_SHA="$(COMMIT_SHA)" -f ./Dockerfile ..
2528

2629
.PHONY: test
2730
test:

packages/nomad-nodepool-apm/Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ RUN go mod download
1313
COPY . .
1414

1515
# Build the plugin
16-
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o /nomad-nodepool-apm .
16+
ARG TARGETARCH
17+
RUN CGO_ENABLED=0 GOOS=linux GOARCH=${TARGETARCH} go build -o /nomad-nodepool-apm .
1718

1819
# Final stage - minimal image just to copy the binary from
1920
FROM scratch

0 commit comments

Comments
 (0)