Skip to content

Commit a8cec62

Browse files
Add multi-arch support for amd64 and arm64 into Dockerfile (#758)
* Add multi-arch support for amd64 and arm64 into Dockerfile Signed-off-by: michal.gubricky <michal.gubricky@dnation.cloud> * Add check for the buildx docker plugin in dev-prerequests Signed-off-by: michal.gubricky <michal.gubricky@dnation.cloud> --------- Signed-off-by: michal.gubricky <michal.gubricky@dnation.cloud>
1 parent 79e291d commit a8cec62

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

Tests/kaas/kaas-sonobuoy-go-example-e2e-framework/Dockerfile

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
11
FROM golang:1.23
22

3-
# Install kubectl
4-
# Note: Latest version may be found on:
5-
# https://aur.archlinux.org/packages/kubectl-bin/
6-
RUN wget https://storage.googleapis.com/kubernetes-release/release/v1.21.3/bin/linux/amd64/kubectl -O /usr/bin/kubectl && \
7-
chmod +x /usr/bin/kubectl && \
8-
apt-get update && \
9-
apt-get install -y jq
3+
# Use build arguments to get the correct architecture
4+
ARG TARGETARCH
5+
6+
# Install kubectl based on the architecture
7+
#See https://github.com/kubernetes-sigs/kubespray/pull/10066
8+
RUN apt-get update && apt-get install -y wget jq && \
9+
if [ "$TARGETARCH" = "amd64" ]; then \
10+
wget https://cdn.dl.k8s.io/release/v1.31.1/bin/linux/amd64/kubectl -O /usr/bin/kubectl; \
11+
elif [ "$TARGETARCH" = "arm64" ]; then \
12+
wget https://cdn.dl.k8s.io/release/v1.31.1/bin/linux/arm64/kubectl -O /usr/bin/kubectl; \
13+
else \
14+
echo "Unsupported architecture: $TARGETARCH" && exit 1; \
15+
fi && \
16+
chmod +x /usr/bin/kubectl
1017

1118
COPY ./scs_k8s_tests /src/scs_k8s_tests
1219
WORKDIR /src
@@ -19,5 +26,3 @@ RUN --mount=type=cache,target=/root/.cache/go-build \
1926
go test -c -o custom.test ./...
2027

2128
CMD ["bash", "-c", "go tool test2json ./custom.test -test.v"]
22-
23-

Tests/kaas/kaas-sonobuoy-go-example-e2e-framework/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ dev-prerequests:
5757
@docker version
5858
@sonobuoy version --short
5959
@go version
60+
@docker buildx version
6061

6162

6263
dev-setup: kind-init

0 commit comments

Comments
 (0)