mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-11-17 11:50:18 +00:00
build: error out when Podman or Docker is not available
In case Podman or Docker is not installed, running containerized tests or builds will fail with unclear errors. Introduce a 'need-container-cmd' make target that checks if the CONTAINER_CMD is available (and non-empty). When running without Podman and Docker, the following error is displayed: $ make containerized-build cephcsi image settings: quay.io/cephcsi/cephcsi version canary Missing container support, install Podman or Docker make: *** [Makefile:135: need-container-cmd] Error 1 Signed-off-by: Niels de Vos <ndevos@redhat.com>
This commit is contained in:
parent
34593c9af0
commit
969b032f1c
17
Makefile
17
Makefile
@ -12,7 +12,7 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
.PHONY: all cephcsi check-env
|
||||
.PHONY: all cephcsi check-env need-container-cmd
|
||||
|
||||
CONTAINER_CMD?=$(shell docker version >/dev/null 2>&1 && echo docker)
|
||||
ifeq ($(CONTAINER_CMD),)
|
||||
@ -130,33 +130,36 @@ cephcsi: check-env
|
||||
e2e.test: check-env
|
||||
go test $(GO_TAGS) -mod=vendor -c ./e2e
|
||||
|
||||
need-container-cmd:
|
||||
@test -n "$(shell which $(CONTAINER_CMD) 2>/dev/null)" || { echo "Missing container support, install Podman or Docker"; exit 1; }
|
||||
|
||||
.PHONY: containerized-build containerized-test
|
||||
containerized-build: TARGET = cephcsi
|
||||
containerized-build: .devel-container-id
|
||||
containerized-build: need-container-cmd .devel-container-id
|
||||
$(CONTAINER_CMD) run --rm -v $(CURDIR):/go/src/github.com/ceph/ceph-csi$(SELINUX_VOL_FLAG) $(CSI_IMAGE_NAME):devel make $(TARGET)
|
||||
|
||||
containerized-test: TARGET = test
|
||||
containerized-test: .test-container-id
|
||||
containerized-test: need-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)
|
||||
|
||||
# create a (cached) container image with dependencied for building cephcsi
|
||||
.devel-container-id: scripts/Dockerfile.devel
|
||||
.devel-container-id: need-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
|
||||
|
||||
# create a (cached) container image with dependencied for testing cephcsi
|
||||
.test-container-id: build.env scripts/Dockerfile.test
|
||||
.test-container-id: need-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
|
||||
|
||||
image-cephcsi: GOARCH ?= $(shell go env GOARCH 2>/dev/null)
|
||||
image-cephcsi:
|
||||
image-cephcsi: need-container-cmd
|
||||
$(CONTAINER_CMD) build $(CPUSET) -t $(CSI_IMAGE) -f deploy/cephcsi/image/Dockerfile . --build-arg CSI_IMAGE_NAME=$(CSI_IMAGE_NAME) --build-arg CSI_IMAGE_VERSION=$(CSI_IMAGE_VERSION) --build-arg GIT_COMMIT=$(GIT_COMMIT) --build-arg GO_ARCH=$(GOARCH) --build-arg BASE_IMAGE=$(BASE_IMAGE)
|
||||
|
||||
push-image-cephcsi: GOARCH ?= $(shell go env GOARCH 2>/dev/null)
|
||||
push-image-cephcsi: image-cephcsi
|
||||
push-image-cephcsi: need-container-cmd image-cephcsi
|
||||
$(CONTAINER_CMD) tag $(CSI_IMAGE) $(CSI_IMAGE)-$(GOARCH)
|
||||
$(CONTAINER_CMD) push $(CSI_IMAGE)-$(GOARCH)
|
||||
# push amd64 image as default one
|
||||
|
Loading…
Reference in New Issue
Block a user