From afd6994e197a3e4bcd4dcc9c46d57dbce1edf707 Mon Sep 17 00:00:00 2001 From: Niels de Vos Date: Mon, 2 Nov 2020 16:57:19 +0100 Subject: [PATCH] ci: allow passing USE_PULLED_IMAGE=yes to use pre-pulled images When passing USE_PULLED_IMAGE=yes to the containerized-test or containerized-build make targets, it is now possible to use pre-pulled container images. This saves time as the container images will not get created from scratch. Signed-off-by: Niels de Vos --- Makefile | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Makefile b/Makefile index e79d00150..f61a385bb 100644 --- a/Makefile +++ b/Makefile @@ -25,6 +25,9 @@ CSI_IMAGE_NAME=$(if $(ENV_CSI_IMAGE_NAME),$(ENV_CSI_IMAGE_NAME),quay.io/cephcsi/ CSI_IMAGE_VERSION=$(if $(ENV_CSI_IMAGE_VERSION),$(ENV_CSI_IMAGE_VERSION),canary) CSI_IMAGE=$(CSI_IMAGE_NAME):$(CSI_IMAGE_VERSION) +# Pass USE_PULLED_IMAGE=yes to skip building a new :test or :devel image. +USE_PULLED_IMAGE?=no + $(info cephcsi image settings: $(CSI_IMAGE_NAME) version $(CSI_IMAGE_VERSION)) ifndef GIT_COMMIT GIT_COMMIT=$(shell git rev-list -1 HEAD) @@ -168,17 +171,29 @@ containerized-test: REBASE ?= 0 containerized-test: .container-cmd .test-container-id $(CONTAINER_CMD) run --rm -v $(CURDIR):/go/src/github.com/ceph/ceph-csi$(SELINUX_VOL_FLAG) $(CSI_IMAGE_NAME):test make $(TARGET) GIT_SINCE=$(GIT_SINCE) REBASE=$(REBASE) +ifeq ($(USE_PULLED_IMAGE),no) # create a (cached) container image with dependencied for building cephcsi .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) inspect -f '{{.Id}}' $(CSI_IMAGE_NAME):devel > .devel-container-id +else +# create the .devel-container-id file based on pulled image +.devel-container-id: .container-cmd + $(CONTAINER_CMD) inspect -f '{{.Id}}' $(CSI_IMAGE_NAME):devel > .devel-container-id +endif +ifeq ($(USE_PULLED_IMAGE),no) # create a (cached) container image with dependencied 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) inspect -f '{{.Id}}' $(CSI_IMAGE_NAME):test > .test-container-id +else +# create the .test-container-id file based on the pulled image +.test-container-id: .container-cmd + $(CONTAINER_CMD) inspect -f '{{.Id}}' $(CSI_IMAGE_NAME):test > .test-container-id +endif image-cephcsi: GOARCH ?= $(shell go env GOARCH 2>/dev/null) image-cephcsi: .container-cmd