Skip to content

Commit

Permalink
Dockerfile: cross compile images using native builder
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
willnorris committed Jan 10, 2023
1 parent ef7f8b2 commit 3af59c5
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
FROM cgr.dev/chainguard/go:1.19-musl as build
FROM --platform=$BUILDPLATFORM cgr.dev/chainguard/go:1.19 as build

WORKDIR /work

COPY go.mod go.sum ./
RUN go mod download

COPY . .
RUN CGO_ENABLED=0 GOOS=linux go build -v ./cmd/golink
ARG TARGETOS TARGETARCH TARGETVARIANT
RUN \
if [ "${TARGETARCH}" = "arm" ] && [ -n "${TARGETVARIANT}" ]; then \
export GOARM="${TARGETVARIANT#v}"; \
fi; \
GOOS=${TARGETOS} GOARCH=${TARGETARCH} CGO_ENABLED=0 go build -v ./cmd/golink


FROM cgr.dev/chainguard/static:latest
Expand Down

0 comments on commit 3af59c5

Please sign in to comment.