Cleanup some commands in Makefile

This commit is contained in:
Ayaz Salikhov
2024-01-17 15:56:18 +04:00
parent afe30f0c9a
commit 5d68244bb2

View File

@@ -2,13 +2,14 @@
# Distributed under the terms of the Modified BSD License. # Distributed under the terms of the Modified BSD License.
.PHONY: docs help test .PHONY: docs help test
# Use bash for inline if-statements in arch_patch target
SHELL:=bash SHELL:=bash
REGISTRY?=quay.io REGISTRY?=quay.io
OWNER?=jupyter OWNER?=jupyter
# Need to list the images in build dependency order # Enable BuildKit for Docker build
# All of the images export DOCKER_BUILDKIT:=1
# All the images listed in the build dependency order
ALL_IMAGES:= \ ALL_IMAGES:= \
docker-stacks-foundation \ docker-stacks-foundation \
base-notebook \ base-notebook \
@@ -22,9 +23,6 @@ ALL_IMAGES:= \
pyspark-notebook \ pyspark-notebook \
all-spark-notebook all-spark-notebook
# Enable BuildKit for Docker build
export DOCKER_BUILDKIT:=1
# https://marmelab.com/blog/2016/02/29/auto-documented-makefile.html # https://marmelab.com/blog/2016/02/29/auto-documented-makefile.html
@@ -52,13 +50,13 @@ check-outdated-all: $(foreach I, $(ALL_IMAGES), check-outdated/$(I)) ## check al
cont-clean-all: cont-stop-all cont-rm-all ## clean all containers (stop + rm)
cont-stop-all: ## stop all containers cont-stop-all: ## stop all containers
@echo "Stopping all containers ..." @echo "Stopping all containers ..."
-docker stop --time 0 $(shell docker ps --all --quiet) 2> /dev/null -docker stop --time 0 $(shell docker ps --all --quiet) 2> /dev/null
cont-rm-all: ## remove all containers cont-rm-all: ## remove all containers
@echo "Removing all containers ..." @echo "Removing all containers ..."
-docker rm --force $(shell docker ps --all --quiet) 2> /dev/null -docker rm --force $(shell docker ps --all --quiet) 2> /dev/null
cont-clean-all: cont-stop-all cont-rm-all ## clean all containers (stop + rm)
@@ -77,18 +75,18 @@ hook-all: $(foreach I, $(ALL_IMAGES), hook/$(I)) ## run post-build hooks for all
img-clean: img-rm-dang img-rm ## clean dangling and jupyter images
img-list: ## list jupyter images img-list: ## list jupyter images
@echo "Listing $(OWNER) images ..." @echo "Listing $(OWNER) images ..."
docker images "$(OWNER)/*" docker images "$(OWNER)/*"
docker images "*/$(OWNER)/*" docker images "*/$(OWNER)/*"
img-rm: ## remove jupyter images
@echo "Removing $(OWNER) images ..."
-docker rmi --force $(shell docker images --quiet "$(OWNER)/*") 2> /dev/null
-docker rmi --force $(shell docker images --quiet "*/$(OWNER)/*") 2> /dev/null
img-rm-dang: ## remove dangling images (tagged None) img-rm-dang: ## remove dangling images (tagged None)
@echo "Removing dangling images ..." @echo "Removing dangling images ..."
-docker rmi --force $(shell docker images -f "dangling=true" --quiet) 2> /dev/null -docker rmi --force $(shell docker images -f "dangling=true" --quiet) 2> /dev/null
img-rm-jupyter: ## remove jupyter images
@echo "Removing $(OWNER) images ..."
-docker rmi --force $(shell docker images --quiet "$(OWNER)/*") 2> /dev/null
-docker rmi --force $(shell docker images --quiet "*/$(OWNER)/*") 2> /dev/null
img-rm: img-rm-dang img-rm-jupyter ## remove dangling and jupyter images