Skip to content

Commit 197f503

Browse files
committed
multi-platform Containerfile and remove QEMU
Signed-off-by: Joseph <[email protected]>
1 parent 5998e93 commit 197f503

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

.github/workflows/quay_binaries_push.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,6 @@ jobs:
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

Containerfile.download

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
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

69
WORKDIR /app
710

@@ -10,16 +13,22 @@ RUN go mod download && go mod verify
1013

1114
COPY . .
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
1418
RUN 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

0 commit comments

Comments
 (0)