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