diff --git a/Dockerfile b/Dockerfile index 1e7e33f8..368c44ab 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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