Dockerfile now use the platform supplied by buildx

This commit is contained in:
Jonathan Drolet
2021-03-15 21:11:18 -04:00
parent 52b975ef0d
commit 68fd3bebe5
+5 -2
View File
@@ -1,5 +1,8 @@
# Build the manager binary
FROM golang:1.15.2 as builder
FROM --platform=${BUILDPLATFORM} golang:1.15.2 as builder
ARG TARGETOS
ARG TARGETARCH
WORKDIR /workspace
@@ -16,7 +19,7 @@ COPY internal/ internal/
COPY pkg/ pkg/
# Build
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -mod=mod -a -o manager main.go
RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} GO111MODULE=on go build -mod=mod -a -o manager main.go
# Use distroless as minimal base image to package the manager binary
# Refer to https://github.com/GoogleContainerTools/distroless for more details