From 8a3fe53e87116663fcce0b2ea20335d482f5fbf9 Mon Sep 17 00:00:00 2001 From: Madhu Rajanna Date: Tue, 14 Dec 2021 09:44:47 +0530 Subject: [PATCH] ci: install arch specific go in Dockerfile.devel Instead of installing the amd64 on all the platforms, install architecture specific go version for devel dockerfile Signed-off-by: Madhu Rajanna --- Makefile | 3 ++- scripts/Dockerfile.devel | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 1ed2ad5ef..3f6f4b079 100644 --- a/Makefile +++ b/Makefile @@ -200,9 +200,10 @@ containerized-test: .container-cmd .test-container-id ifeq ($(USE_PULLED_IMAGE),no) # create a (cached) container image with dependencies for building cephcsi +.devel-container-id: GOARCH ?= $(shell go env GOARCH 2>/dev/null) .devel-container-id: .container-cmd scripts/Dockerfile.devel [ ! -f .devel-container-id ] || $(CONTAINER_CMD) rmi $(CSI_IMAGE_NAME):devel - $(CONTAINER_CMD) build $(CPUSET) --build-arg BASE_IMAGE=$(BASE_IMAGE) -t $(CSI_IMAGE_NAME):devel -f ./scripts/Dockerfile.devel . + $(CONTAINER_CMD) build $(CPUSET) --build-arg BASE_IMAGE=$(BASE_IMAGE) --build-arg GOARCH=$(GOARCH) -t $(CSI_IMAGE_NAME):devel -f ./scripts/Dockerfile.devel . $(CONTAINER_CMD) inspect -f '{{.Id}}' $(CSI_IMAGE_NAME):devel > .devel-container-id else # create the .devel-container-id file based on pulled image diff --git a/scripts/Dockerfile.devel b/scripts/Dockerfile.devel index d4d81f98b..c74bcd7d5 100644 --- a/scripts/Dockerfile.devel +++ b/scripts/Dockerfile.devel @@ -2,6 +2,7 @@ ARG BASE_IMAGE FROM ${BASE_IMAGE} ARG GOROOT=/usr/local/go +ARG GOARCH ENV GOPATH=/go \ GOROOT=${GOROOT} \ @@ -11,8 +12,10 @@ ENV GOPATH=/go \ 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-build GOARCH=amd64\n\n"; exit 1 ) \ && mkdir -p /usr/local/go \ - && curl https://storage.googleapis.com/golang/go${GOLANG_VERSION}.linux-amd64.tar.gz | tar xzf - -C ${GOROOT} --strip-components=1 + && curl https://storage.googleapis.com/golang/go${GOLANG_VERSION}.linux-${GOARCH}.tar.gz | tar xzf - -C ${GOROOT} --strip-components=1 RUN dnf -y install \ git \