File tree Expand file tree Collapse file tree 2 files changed +14
-10
lines changed
Expand file tree Collapse file tree 2 files changed +14
-10
lines changed Original file line number Diff line number Diff line change 2727 with :
2828 go-version-file : go.mod
2929 cache : true
30-
31- - name : Install qemu dependency
32- run : |
33- sudo apt-get update
34- sudo apt-get install -y qemu-user-static
3530
3631 - name : Build Image for ${{ matrix.arch }}
3732 id : build_image
Original file line number Diff line number Diff line change 11# This Dockerfile is used to cross-build the kubectl-oadp binaries for all platforms
22# It also builds a Go server that serves the binaries for download
33
4- FROM golang:1.24 AS builder
4+ FROM --platform=$BUILDPLATFORM golang:1.24 AS builder
5+
6+ ARG TARGETOS
7+ ARG TARGETARCH
58
69WORKDIR /app
710
@@ -10,16 +13,22 @@ RUN go mod download && go mod verify
1013
1114COPY . .
1215
13- # Build everything, create tarballs, and clean up in one layer to reduce size
16+ # Build ALL kubectl-oadp binaries using native Go cross-compilation (no QEMU emulation)
17+ # The download server needs to serve binaries for all platforms, not just one arch
1418RUN make release-build && \
15- CGO_ENABLED=0 go build -o download-server ./cmd/downloads/server.go && \
1619 mkdir -p /archives && \
1720 for binary in kubectl-oadp_*; do \
1821 archive_name=$(echo "$binary" | sed 's/\.exe$//' ).tar.gz; \
1922 tar -czf "/archives/$archive_name" "$binary"; \
2023 echo "Created /archives/$archive_name"; \
21- done && \
22- go clean -cache -modcache -testcache && \
24+ done
25+
26+ # Build the download server for the TARGET platform (the arch this container will run on)
27+ # This uses cross-compilation so the builder can run natively on amd64
28+ RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -o download-server ./cmd/downloads/server.go
29+
30+ # Clean up to reduce layer size
31+ RUN go clean -cache -modcache -testcache && \
2332 rm -rf /root/.cache/go-build && \
2433 rm -rf /go/pkg
2534
You can’t perform that action at this time.
0 commit comments