File tree Expand file tree Collapse file tree 3 files changed +11
-7
lines changed
Expand file tree Collapse file tree 3 files changed +11
-7
lines changed Original file line number Diff line number Diff line change 11# Build the manager binary
2- FROM golang:1.25.8-trixie AS builder
2+ FROM --platform=$BUILDPLATFORM golang:1.25.8-trixie as builder
33
44WORKDIR /workspace/api
55COPY api/ .
@@ -20,11 +20,13 @@ COPY controllers/ controllers/
2020COPY utils/ utils/
2121
2222# Build
23- RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -a -o manager main.go
23+ ARG TARGETOS
24+ ARG TARGETARCH
25+ RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH:-amd64} GO111MODULE=on go build -a -o manager main.go
2426
2527# Use distroless as minimal base image to package the manager binary
2628# Refer to https://github.com/GoogleContainerTools/distroless for more details
27- FROM gcr.io/distroless/static:nonroot
29+ FROM --platform=$TARGETPLATFORM gcr.io/distroless/static:nonroot
2830WORKDIR /
2931COPY --from=builder /workspace/manager .
3032USER 65532:65532
Original file line number Diff line number Diff line change 1- FROM alpine:3.21
1+ FROM --platform=$TARGETPLATFORM alpine:3.21
22
33ENV GID=10001
44ENV UID=10000
Original file line number Diff line number Diff line change 11# Build the manager binary
2- FROM golang:1.25.8-trixie as builder
2+ FROM --platform=$BUILDPLATFORM golang:1.25.8-trixie AS builder
33
44WORKDIR /workspace/api
55COPY api/ .
@@ -20,12 +20,14 @@ COPY controllers/ controllers/
2020COPY utils/ utils/
2121
2222# Build
23- RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -a -o manager main.go
23+ ARG TARGETOS
24+ ARG TARGETARCH
25+ RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH:-amd64} GO111MODULE=on go build -a -o manager main.go
2426
2527# Use ubi image as the base image which is required by the red hat certification.
2628# Base on the image size, the order is ubi > ubi-minimal > ubi-micro.
2729# https://access.redhat.com/documentation/en-us/red_hat_software_certification/8.45/html/red_hat_openshift_software_certification_policy_guide/assembly-requirements-for-container-images_openshift-sw-cert-policy-introduction#con-image-metadata-requirements_openshift-sw-cert-policy-container-images
28- FROM registry.access.redhat.com/ubi8/ubi-micro:latest
30+ FROM --platform=$TARGETPLATFORM registry.access.redhat.com/ubi8/ubi-micro:latest
2931
3032ARG VERSION
3133
You can’t perform that action at this time.
0 commit comments