From 706efd59133e72608cf57e6cdde8d6a0d32583ca Mon Sep 17 00:00:00 2001 From: Will Norris Date: Mon, 9 Jan 2023 17:01:46 -0800 Subject: [PATCH] Dockerfile: cross compile images using native builder Use a build image built for the native architecture so that it doesn't run in emulation mode. Switch to Chainguard's wolfi/glibc build image. This limits our build architectures to just amd64 and arm64, but that is sufficient for our needs. Updates #42 Updates #43 Signed-off-by: Will Norris --- Dockerfile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 71a7fd9..eba7aa8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM cgr.dev/chainguard/go:1.19-musl as build +FROM --platform=$BUILDPLATFORM cgr.dev/chainguard/go:1.19 as build WORKDIR /work @@ -6,7 +6,8 @@ COPY go.mod go.sum ./ RUN go mod download COPY . . -RUN CGO_ENABLED=0 GOOS=linux go build -v ./cmd/golink +ARG TARGETOS TARGETARCH +RUN CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH go build -v ./cmd/golink FROM cgr.dev/chainguard/static:latest