Skip to content

Commit 27ff90d

Browse files
committed
fix(ci): build the operator image natively for multi-arch
Pin the Dockerfile builder stage to $BUILDPLATFORM so a buildx --platform=linux/amd64,linux/arm64 build cross-compiles via GOARCH instead of running go build under emulation; without it the arm64 leg fails with exec format error on an amd64 runner with no QEMU. Add a no-QEMU multi-arch build-only CI job that fails closed if the pin regresses. Signed-off-by: Timofei Larkin <lllamnyp@gmail.com>
1 parent 7b04604 commit 27ff90d

2 files changed

Lines changed: 21 additions & 2 deletions

File tree

.github/workflows/ci.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,20 @@ on:
77
branches: [ main ]
88

99
jobs:
10+
image-multiarch:
11+
# Build-only assertion that the operator image builds for every published
12+
# platform. Deliberately sets up buildx WITHOUT QEMU: the Dockerfile builder
13+
# is pinned to $BUILDPLATFORM and Go cross-compiles via GOARCH, so both legs
14+
# must build natively on this amd64 runner with no emulation. If the
15+
# --platform=$BUILDPLATFORM pin regresses, the arm64 leg fails here (exec
16+
# format error) instead of silently breaking the tag-release publish.
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: actions/checkout@v4
20+
- uses: docker/setup-buildx-action@v3.3.0
21+
- name: Build multi-arch image (no push, no QEMU)
22+
run: docker buildx build --platform linux/amd64,linux/arm64 -t etcd-operator:buildtest .
23+
1024
verify:
1125
runs-on: ubuntu-latest
1226
steps:

Dockerfile

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1-
# Build the manager binary
2-
FROM golang:1.25.10 AS builder
1+
# Build the manager binary.
2+
# Pin the builder to the BUILD platform so a multi-arch `buildx --platform`
3+
# build runs the builder natively (no QEMU) and Go cross-compiles via the
4+
# GOARCH=${TARGETARCH} below. Without this, buildx instantiates the builder as
5+
# the target arch and `go build` runs under emulation — which fails the arm64
6+
# leg on an amd64 runner that has no binfmt registered.
7+
FROM --platform=$BUILDPLATFORM golang:1.25.10 AS builder
38
ARG TARGETOS
49
ARG TARGETARCH
510

0 commit comments

Comments
 (0)