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}" \