Skip to content

Commit

Permalink
Build multi-architectures image (#1100)
Browse files Browse the repository at this point in the history
  • Loading branch information
int128 authored Jun 6, 2024
1 parent 4ace91e commit 12fe32c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ jobs:
needs: go-version
uses: int128/docker-build-workflow/.github/workflows/build.yaml@v1
with:
platforms: linux/amd64,linux/arm64
build-args: go_version=${{ needs.go-version.outputs.go-version }}

e2e-test:
Expand Down
8 changes: 4 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# Build the manager binary
ARG go_version
FROM golang:${go_version} as builder
ARG TARGETOS
ARG TARGETARCH
FROM --platform=$BUILDPLATFORM golang:${go_version} as builder

WORKDIR /workspace
# Copy the Go Modules manifests
Expand All @@ -17,6 +15,8 @@ COPY cmd/main.go cmd/main.go
COPY api/ api/
COPY internal/ internal/

ARG TARGETOS TARGETARCH

# Build
# the GOARCH has not a default value to allow the binary be built according to the host where the command
# was called. For example, if we call make docker-build in a local env which has the Apple Silicon M1 SO
Expand All @@ -26,7 +26,7 @@ RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -a -o ma

# 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:nonroot
FROM gcr.io/distroless/static-debian12:nonroot
WORKDIR /
COPY --from=builder /workspace/manager .
USER 65532:65532
Expand Down

0 comments on commit 12fe32c

Please sign in to comment.