Skip to content

Commit 2c4f574

Browse files
authored
feat: use TARGETARCH to support cross-platform multi-arch builds (#97)
On-behalf-of: @SAP <simon@simontesar.com>
1 parent cbc1840 commit 2c4f574

1 file changed

Lines changed: 4 additions & 10 deletions

File tree

Dockerfile

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,19 @@
11
FROM --platform=$BUILDPLATFORM golang:1.25@sha256:36b4f45d2874905b9e8573b783292629bcb346d0a70d8d7150b6df545234818f AS builder
2+
ARG TARGETARCH
23

34
WORKDIR /workspace
45

56
COPY go.mod go.sum ./
6-
RUN --mount=type=cache,target=/go/pkg/mod \
7-
go mod download && go mod verify
7+
RUN go mod download
88

99
COPY . .
10-
RUN --mount=type=cache,target=/go/pkg/mod/ \
11-
--mount=type=cache,target=/root/.cache/go-build \
12-
CGO_ENABLED=0 \
13-
GOCACHE=/root/.cache/go-build \
14-
GOOS=$TARGETOS \
15-
GOARCH=$TARGETARCH \
16-
make build
10+
RUN CGO_ENABLED=0 GOOS=linux GOARCH=${TARGETARCH} go build -a -o manager cmd/main.go
1711

1812
# Use distroless base-debian11 image to include shell access while keeping minimal footprint
1913
# Refer to https://github.com/GoogleContainerTools/distroless for more details
2014
FROM gcr.io/distroless/base-debian11:debug@sha256:68e5ea65df0f5d135083d4cc1df5fc16855d61ed628254df8e1affa8ce2d3244
2115
WORKDIR /
22-
COPY --from=builder /workspace/bin/manager .
16+
COPY --from=builder /workspace/manager .
2317
USER 65532:65532
2418

2519
ENTRYPOINT ["/manager"]

0 commit comments

Comments
 (0)