Skip to content

Commit

Permalink
add: multiarch docker image build (#1059)
Browse files Browse the repository at this point in the history
  • Loading branch information
akatona84 committed Oct 10, 2023
1 parent 158c5bb commit 6b2b109
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
- "v?[0-9]+.[0-9]+.[0-9]+-dev.[0-9]+"
# pull_request:
env:
PLATFORMS: linux/amd64
PLATFORMS: linux/amd64,linux/arm64
jobs:
docker:
name: Docker
Expand Down
12 changes: 9 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Build the manager binary
FROM golang:1.19 as builder
FROM --platform=${BUILDPLATFORM:-linux/amd64} golang:1.19 as builder

ARG BUILDPLATFORM
ARG TARGETPLATFORM
ARG TARGETOS
ARG TARGETARCH
RUN echo "BUILDPLATFORM: ${BUILDPLATFORM}, TARGETPLATFORM: ${TARGETPLATFORM}, TARGETOS: ${TARGETOS}, TARGETARCH: ${TARGETARCH}"

WORKDIR /workspace
# Copy the Go Modules manifests
Expand All @@ -18,11 +24,11 @@ COPY internal/ internal/
COPY pkg/ pkg/

# Build
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -a -o manager main.go
RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH:-amd64} GO111MODULE=on 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
FROM gcr.io/distroless/static-debian11:nonroot
FROM --platform=${TARGETPLATFORM:-linux/amd64} gcr.io/distroless/static-debian11:nonroot
WORKDIR /
COPY --from=builder /workspace/manager .
ENTRYPOINT ["/manager"]

0 comments on commit 6b2b109

Please sign in to comment.