Skip to content
This repository was archived by the owner on Mar 26, 2025. It is now read-only.

Commit 6b2b109

Browse files
authored
add: multiarch docker image build (#1059)
1 parent 158c5bb commit 6b2b109

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

.github/workflows/docker.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ on:
99
- "v?[0-9]+.[0-9]+.[0-9]+-dev.[0-9]+"
1010
# pull_request:
1111
env:
12-
PLATFORMS: linux/amd64
12+
PLATFORMS: linux/amd64,linux/arm64
1313
jobs:
1414
docker:
1515
name: Docker

Dockerfile

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Build the manager binary
2-
FROM golang:1.19 as builder
2+
FROM --platform=${BUILDPLATFORM:-linux/amd64} golang:1.19 as builder
3+
4+
ARG BUILDPLATFORM
5+
ARG TARGETPLATFORM
6+
ARG TARGETOS
7+
ARG TARGETARCH
8+
RUN echo "BUILDPLATFORM: ${BUILDPLATFORM}, TARGETPLATFORM: ${TARGETPLATFORM}, TARGETOS: ${TARGETOS}, TARGETARCH: ${TARGETARCH}"
39

410
WORKDIR /workspace
511
# Copy the Go Modules manifests
@@ -18,11 +24,11 @@ COPY internal/ internal/
1824
COPY pkg/ pkg/
1925

2026
# Build
21-
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -a -o manager main.go
27+
RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH:-amd64} GO111MODULE=on go build -a -o manager main.go
2228

2329
# Use distroless as minimal base image to package the manager binary
2430
# Refer to https://github.com/GoogleContainerTools/distroless for more details
25-
FROM gcr.io/distroless/static-debian11:nonroot
31+
FROM --platform=${TARGETPLATFORM:-linux/amd64} gcr.io/distroless/static-debian11:nonroot
2632
WORKDIR /
2733
COPY --from=builder /workspace/manager .
2834
ENTRYPOINT ["/manager"]

0 commit comments

Comments
 (0)