Skip to content

Commit

Permalink
Add multi-arch support for amd64 and arm64 into Dockerfile (#758)
Browse files Browse the repository at this point in the history
* Add multi-arch support for amd64 and arm64 into Dockerfile

Signed-off-by: michal.gubricky <[email protected]>

* Add check for the buildx docker plugin in dev-prerequests

Signed-off-by: michal.gubricky <[email protected]>

---------

Signed-off-by: michal.gubricky <[email protected]>
  • Loading branch information
michal-gubricky authored Sep 26, 2024
1 parent 79e291d commit a8cec62
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
23 changes: 14 additions & 9 deletions Tests/kaas/kaas-sonobuoy-go-example-e2e-framework/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
FROM golang:1.23

# Install kubectl
# Note: Latest version may be found on:
# https://aur.archlinux.org/packages/kubectl-bin/
RUN wget https://storage.googleapis.com/kubernetes-release/release/v1.21.3/bin/linux/amd64/kubectl -O /usr/bin/kubectl && \
chmod +x /usr/bin/kubectl && \
apt-get update && \
apt-get install -y jq
# Use build arguments to get the correct architecture
ARG TARGETARCH

# Install kubectl based on the architecture
#See https://github.com/kubernetes-sigs/kubespray/pull/10066
RUN apt-get update && apt-get install -y wget jq && \
if [ "$TARGETARCH" = "amd64" ]; then \
wget https://cdn.dl.k8s.io/release/v1.31.1/bin/linux/amd64/kubectl -O /usr/bin/kubectl; \
elif [ "$TARGETARCH" = "arm64" ]; then \
wget https://cdn.dl.k8s.io/release/v1.31.1/bin/linux/arm64/kubectl -O /usr/bin/kubectl; \
else \
echo "Unsupported architecture: $TARGETARCH" && exit 1; \
fi && \
chmod +x /usr/bin/kubectl

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

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


1 change: 1 addition & 0 deletions Tests/kaas/kaas-sonobuoy-go-example-e2e-framework/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ dev-prerequests:
@docker version
@sonobuoy version --short
@go version
@docker buildx version


dev-setup: kind-init
Expand Down

0 comments on commit a8cec62

Please sign in to comment.