feat(docker): build according to targetarch

This commit is contained in:
ptx96
2022-05-26 16:33:15 +02:00
committed by Dario Tranchitella
parent 6ee5196928
commit 6cebf0950d

View File

@@ -1,6 +1,8 @@
# Build the manager binary
FROM golang:1.18 as builder
ARG TARGETARCH
WORKDIR /workspace
# Copy the Go Modules manifests
COPY go.mod go.mod
@@ -16,7 +18,7 @@ COPY controllers/ controllers/
COPY internal/ internal/
# Build
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -o manager main.go
RUN CGO_ENABLED=0 GOOS=linux GOARCH=$TARGETARCH go build -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