Skip to content

Commit c1d58ba

Browse files
loafoeclaude
andcommitted
Allow overriding target platform for ko and task-runner builds
ko defaults to linux/amd64 regardless of host, and build-task-runner hardcoded GOOS=linux/GOARCH=amd64 plus --platform linux/amd64, so every deploy target was amd64-only. Add KO_PLATFORM (for the ko-based ax-controller/ax-server builds) and TASK_RUNNER_PLATFORM (for the cross-compiled task-runner image), both defaulting to linux/amd64 to preserve current behavior, so arm64 clusters can override them, e.g.: make deploy AX_IMAGE_REPO=... KO_PLATFORM=linux/arm64 make push TASK_RUNNER_PLATFORM=linux/arm64 Dockerfile.task-runner now takes the arch as a build arg instead of a hardcoded bin/linux_amd64 COPY path. Co-Authored-By: Claude Sonnet 5 <[email protected]>
1 parent d8ed0fe commit c1d58ba

2 files changed

Lines changed: 20 additions & 10 deletions

File tree

‎Dockerfile.task-runner‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414

1515
FROM python:3.12-slim
1616

17+
ARG TASK_RUNNER_GOARCH=amd64
18+
1719
RUN apt-get update && apt-get install -y --no-install-recommends \
1820
git \
1921
curl \
@@ -25,7 +27,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
2527

2628
RUN pip install --no-cache-dir google-antigravity
2729

28-
COPY bin/linux_amd64/ax-task-runner /usr/local/bin/ax-task-runner
30+
COPY bin/linux_${TASK_RUNNER_GOARCH}/ax-task-runner /usr/local/bin/ax-task-runner
2931
COPY cmd/ax-task-runner/antigravity_bootstrap.py /usr/local/bin/antigravity_bootstrap.py
3032

3133
ENTRYPOINT ["/usr/local/bin/ax-task-runner"]

‎Makefile‎

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,14 @@ SHELL := /bin/bash
1818
AX_IMAGE_REPO ?= gcr.io/ax-substrate/ate-images
1919
TASK_RUNNER_REPO ?= $(AX_IMAGE_REPO)/ax-task-runner
2020
CONTAINER_CLI ?= $(shell which podman 2>/dev/null || which docker 2>/dev/null)
21+
# Target platform for ko-built images (ax-controller, ax-server). Override for
22+
# non-amd64 clusters, e.g. make deploy AX_IMAGE_REPO=... KO_PLATFORM=linux/arm64
23+
KO_PLATFORM ?= linux/amd64
24+
# Target platform for the ax-task-runner image (cross-compiled Go binary +
25+
# container build, not built via ko). Override alongside KO_PLATFORM for
26+
# non-amd64 clusters, e.g. TASK_RUNNER_PLATFORM=linux/arm64
27+
TASK_RUNNER_PLATFORM ?= linux/amd64
28+
TASK_RUNNER_GOARCH = $(lastword $(subst /, ,$(TASK_RUNNER_PLATFORM)))
2129

2230
.PHONY: all build build-binaries build-task-runner install push push-task-runner deploy deploy-controller deploy-server deploy-redis apply-example test clean
2331

@@ -42,13 +50,13 @@ install:
4250
@echo "==> Installing ax CLI to $$(go env GOPATH)/bin..."
4351
go install -trimpath -ldflags="-s -w" ./cmd/ax
4452

45-
# Cross-compile ax-task-runner for Linux amd64 and build container image with Python, Antigravity, and git/curl
53+
# Cross-compile ax-task-runner for TASK_RUNNER_PLATFORM and build container image with Python, Antigravity, and git/curl
4654
build-task-runner:
47-
@echo "==> Cross-compiling ax-task-runner for linux/amd64..."
48-
@mkdir -p bin/linux_amd64
49-
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -trimpath -ldflags="-s -w" -o bin/linux_amd64/ax-task-runner ./cmd/ax-task-runner
55+
@echo "==> Cross-compiling ax-task-runner for $(TASK_RUNNER_PLATFORM)..."
56+
@mkdir -p bin/linux_$(TASK_RUNNER_GOARCH)
57+
GOOS=linux GOARCH=$(TASK_RUNNER_GOARCH) CGO_ENABLED=0 go build -trimpath -ldflags="-s -w" -o bin/linux_$(TASK_RUNNER_GOARCH)/ax-task-runner ./cmd/ax-task-runner
5058
@echo "==> Building container image $(TASK_RUNNER_REPO):latest using $(CONTAINER_CLI)..."
51-
$(CONTAINER_CLI) build --platform linux/amd64 -t $(TASK_RUNNER_REPO):latest -f Dockerfile.task-runner .
59+
$(CONTAINER_CLI) build --platform $(TASK_RUNNER_PLATFORM) --build-arg TASK_RUNNER_GOARCH=$(TASK_RUNNER_GOARCH) -t $(TASK_RUNNER_REPO):latest -f Dockerfile.task-runner .
5260

5361
# Push task-runner container image to registry
5462
push-task-runner: build-task-runner
@@ -72,12 +80,12 @@ deploy-redis:
7280
kubectl apply -f deploy/redis.yaml
7381

7482
deploy-controller:
75-
@echo "==> Building and deploying ax-controller using ko..."
76-
KO_DOCKER_REPO=$(AX_IMAGE_REPO) ko apply -f deploy/ax-controller.yaml
83+
@echo "==> Building and deploying ax-controller using ko (platform: $(KO_PLATFORM))..."
84+
KO_DOCKER_REPO=$(AX_IMAGE_REPO) ko apply --platform=$(KO_PLATFORM) -f deploy/ax-controller.yaml
7785

7886
deploy-server:
79-
@echo "==> Building and deploying ax-server using ko..."
80-
KO_DOCKER_REPO=$(AX_IMAGE_REPO) ko apply -f deploy/ax-server.yaml
87+
@echo "==> Building and deploying ax-server using ko (platform: $(KO_PLATFORM))..."
88+
KO_DOCKER_REPO=$(AX_IMAGE_REPO) ko apply --platform=$(KO_PLATFORM) -f deploy/ax-server.yaml
8189

8290
# Apply example task and resources
8391
apply-example:

0 commit comments

Comments
 (0)