From e743e06748aebd54a22f7e692e051e7a31ee4457 Mon Sep 17 00:00:00 2001 From: Madhu Rajanna Date: Tue, 14 Dec 2021 09:46:47 +0530 Subject: [PATCH] ci: install arch specific go in Dockerfile.test Instead of installing the amd64 on all the platforms, install architecture specific go version in test dockerfile. Signed-off-by: Madhu Rajanna --- Makefile | 3 ++- scripts/Dockerfile.test | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 3f6f4b079..9c457942a 100644 --- a/Makefile +++ b/Makefile @@ -212,10 +212,11 @@ else endif ifeq ($(USE_PULLED_IMAGE),no) +.test-container-id: GOARCH ?= $(shell go env GOARCH 2>/dev/null) # create a (cached) container image with dependencies for testing cephcsi .test-container-id: .container-cmd build.env scripts/Dockerfile.test [ ! -f .test-container-id ] || $(CONTAINER_CMD) rmi $(CSI_IMAGE_NAME):test - $(CONTAINER_CMD) build $(CPUSET) -t $(CSI_IMAGE_NAME):test -f ./scripts/Dockerfile.test . + $(CONTAINER_CMD) build $(CPUSET) --build-arg GOARCH=$(GOARCH) -t $(CSI_IMAGE_NAME):test -f ./scripts/Dockerfile.test . $(CONTAINER_CMD) inspect -f '{{.Id}}' $(CSI_IMAGE_NAME):test > .test-container-id else # create the .test-container-id file based on the pulled image diff --git a/scripts/Dockerfile.test b/scripts/Dockerfile.test index 5a67a7db0..e5b000c7f 100644 --- a/scripts/Dockerfile.test +++ b/scripts/Dockerfile.test @@ -12,6 +12,7 @@ FROM registry.fedoraproject.org/fedora:latest ARG GOPATH=/go ARG GOROOT=/usr/local/go +ARG GOARCH ENV \ GOPATH=${GOPATH} \ @@ -22,6 +23,8 @@ ENV \ COPY build.env / RUN source /build.env \ + && \ + ( test -n "${GOARCH}" && exit 0; echo -e "\n\nMissing GOARCH argument for building image, install Golang or run: make containerized-test GOARCH=amd64\n\n"; exit 1 ) \ && dnf -y install \ git \ make \ @@ -41,7 +44,7 @@ RUN source /build.env \ && dnf -y clean all \ && gem install mdl \ && mkdir -p ${GOROOT} \ - && curl https://storage.googleapis.com/golang/go${GOLANG_VERSION}.linux-amd64.tar.gz \ + && curl https://storage.googleapis.com/golang/go${GOLANG_VERSION}.linux-${GOARCH}.tar.gz \ | tar xzf - -C ${GOROOT} --strip-components=1 \ && curl -sf "https://install.goreleaser.com/github.com/golangci/golangci-lint.sh" \ | bash -s -- -b ${GOPATH}/bin "${GOLANGCI_VERSION}" \