mirror of
https://github.com/wahyd4/golink.git
synced 2026-08-09 05:05:56 +10:00
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 <will@tailscale.com>
This commit is contained in:
+7
-2
@@ -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,12 @@ 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
|
||||
|
||||
Reference in New Issue
Block a user