From 2017d8b3660564208c16569ebc29109b08d8e4b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C4=81ris=20Pop=C4=93ns?= Date: Sun, 4 Oct 2026 19:36:39 +0300 Subject: [PATCH] perf: cross-compile arm64 instead of building under QEMU --- Dockerfile | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 7777e9e..c877099 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,10 +1,12 @@ # Static CGO-free binary; distroless/static brings CA certs and nothing else. -FROM golang:1.27-trixie AS builder +# Cross-compile on the runner's own arch; building arm64 under QEMU took minutes. +FROM --platform=$BUILDPLATFORM golang:1.27-trixie AS builder +ARG TARGETOS TARGETARCH WORKDIR /src COPY go.mod go.sum ./ RUN go mod download COPY . . -RUN CGO_ENABLED=0 go build -trimpath -ldflags="-s -w" -o /github-actions-runner-exporter . +RUN CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH go build -trimpath -ldflags="-s -w" -o /github-actions-runner-exporter . FROM gcr.io/distroless/static-debian13:nonroot COPY --from=builder /github-actions-runner-exporter /github-actions-runner-exporter