Skip to content

Commit 985e469

Browse files
authored
Merge pull request #1403 from mathbunnyru/asalikhov/refactor_make
Refactor Makefile to improve readability
2 parents 3509286 + 667c4f9 commit 985e469

File tree

2 files changed

+32
-15
lines changed

2 files changed

+32
-15
lines changed

Makefile

Lines changed: 30 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ SHELL:=bash
77
OWNER?=jupyter
88

99
# Need to list the images in build dependency order
10-
ALL_IMAGES:=base-notebook \
10+
ALL_IMAGES:= \
11+
base-notebook \
1112
minimal-notebook \
1213
r-notebook \
1314
scipy-notebook \
@@ -19,6 +20,8 @@ ALL_IMAGES:=base-notebook \
1920
# Enable BuildKit for Docker build
2021
export DOCKER_BUILDKIT:=1
2122

23+
24+
2225
# https://marmelab.com/blog/2016/02/29/auto-documented-makefile.html
2326
help:
2427
@echo "jupyter/docker-stacks"
@@ -27,29 +30,34 @@ help:
2730
@echo
2831
@grep -E '^[a-zA-Z0-9_%/-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
2932

33+
34+
3035
build/%: DARGS?=
3136
build/%: ## build the latest image for a stack
3237
docker build $(DARGS) --rm --force-rm -t $(OWNER)/$(notdir $@):latest --build-arg OWNER=$(OWNER) ./$(notdir $@)
3338
@echo -n "Built image size: "
3439
@docker images $(OWNER)/$(notdir $@):latest --format "{{.Size}}"
40+
build-all: $(foreach I, $(ALL_IMAGES), build/$(I)) ## build all stacks
41+
build-test-all: $(foreach I, $(ALL_IMAGES), build/$(I) test/$(I)) ## build and test all stacks
42+
3543

36-
build-all: $(foreach I,$(ALL_IMAGES), build/$(I) ) ## build all stacks
37-
build-test-all: $(foreach I,$(ALL_IMAGES), build/$(I) test/$(I) ) ## build and test all stacks
3844

3945
check-outdated/%: ## check the outdated conda packages in a stack and produce a report (experimental)
4046
@TEST_IMAGE="$(OWNER)/$(notdir $@)" pytest test/test_outdated.py
41-
check-outdated-all: $(foreach I,$(ALL_IMAGES), check-outdated/$(I) ) ## check all the stacks for outdated conda packages
47+
check-outdated-all: $(foreach I, $(ALL_IMAGES), check-outdated/$(I)) ## check all the stacks for outdated conda packages
48+
4249

43-
cont-clean-all: cont-stop-all cont-rm-all ## clean all containers (stop + rm)
4450

51+
cont-clean-all: cont-stop-all cont-rm-all ## clean all containers (stop + rm)
4552
cont-stop-all: ## stop all containers
4653
@echo "Stopping all containers ..."
4754
-docker stop -t0 $(shell docker ps -a -q) 2> /dev/null
48-
4955
cont-rm-all: ## remove all containers
5056
@echo "Removing all containers ..."
5157
-docker rm --force $(shell docker ps -a -q) 2> /dev/null
5258

59+
60+
5361
dev/%: ARGS?=
5462
dev/%: DARGS?=-e JUPYTER_ENABLE_LAB=yes
5563
dev/%: PORT?=8888
@@ -59,48 +67,53 @@ dev/%: ## run a foreground container for a stack
5967
dev-env: ## install libraries required to build docs and run tests
6068
@pip install -r requirements-dev.txt
6169

70+
71+
6272
docs: ## build HTML documentation
6373
sphinx-build docs/ docs/_build/
6474

75+
76+
6577
hook/%: WIKI_PATH?=../wiki
6678
hook/%: ## run post-build hooks for an image
6779
python3 -m tagging.tag_image --short-image-name "$(notdir $@)" --owner "$(OWNER)" && \
6880
python3 -m tagging.create_manifests --short-image-name "$(notdir $@)" --owner "$(OWNER)" --wiki-path "$(WIKI_PATH)"
81+
hook-all: $(foreach I, $(ALL_IMAGES), hook/$(I)) ## run post-build hooks for all images
6982

70-
hook-all: $(foreach I,$(ALL_IMAGES),hook/$(I) ) ## run post-build hooks for all images
7183

72-
img-clean: img-rm-dang img-rm ## clean dangling and jupyter images
7384

85+
img-clean: img-rm-dang img-rm ## clean dangling and jupyter images
7486
img-list: ## list jupyter images
7587
@echo "Listing $(OWNER) images ..."
7688
docker images "$(OWNER)/*"
77-
7889
img-rm: ## remove jupyter images
7990
@echo "Removing $(OWNER) images ..."
8091
-docker rmi --force $(shell docker images --quiet "$(OWNER)/*") 2> /dev/null
81-
8292
img-rm-dang: ## remove dangling images (tagged None)
8393
@echo "Removing dangling images ..."
8494
-docker rmi --force $(shell docker images -f "dangling=true" -q) 2> /dev/null
8595

96+
97+
8698
pre-commit-all: ## run pre-commit hook on all files
8799
@pre-commit run --all-files || (printf "\n\n\n" && git --no-pager diff --color=always)
88-
89100
pre-commit-install: ## set up the git hook scripts
90101
@pre-commit --version
91102
@pre-commit install
92103

104+
105+
93106
pull/%: DARGS?=
94107
pull/%: ## pull a jupyter image
95108
docker pull $(DARGS) $(OWNER)/$(notdir $@)
96-
97-
pull-all: $(foreach I,$(ALL_IMAGES),pull/$(I) ) ## pull all images
109+
pull-all: $(foreach I, $(ALL_IMAGES), pull/$(I)) ## pull all images
98110

99111
push/%: DARGS?=
100112
push/%: ## push all tags for a jupyter image
101113
docker push --all-tags $(DARGS) $(OWNER)/$(notdir $@)
114+
push-all: $(foreach I, $(ALL_IMAGES), push/$(I)) ## push all tagged images
115+
102116

103-
push-all: $(foreach I,$(ALL_IMAGES),push/$(I) ) ## push all tagged images
104117

105118
run/%: DARGS?=
106119
run/%: ## run a bash in interactive mode in a stack
@@ -110,8 +123,10 @@ run-sudo/%: DARGS?=
110123
run-sudo/%: ## run a bash in interactive mode as root in a stack
111124
docker run -it --rm -u root $(DARGS) $(OWNER)/$(notdir $@) $(SHELL)
112125

126+
127+
113128
test/%: ## run tests against a stack (only common tests or common tests + specific tests)
114129
@if [ ! -d "$(notdir $@)/test" ]; then TEST_IMAGE="$(OWNER)/$(notdir $@)" pytest -m "not info" test; \
115130
else TEST_IMAGE="$(OWNER)/$(notdir $@)" pytest -m "not info" test $(notdir $@)/test; fi
116131

117-
test-all: $(foreach I,$(ALL_IMAGES),test/$(I)) ## test all stacks
132+
test-all: $(foreach I, $(ALL_IMAGES), test/$(I)) ## test all stacks

test/test_packages.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@
6969
"r-irkernel",
7070
"unixodbc",
7171
"bzip2",
72+
"openssl",
73+
"ca-certificates",
7274
]
7375

7476

0 commit comments

Comments
 (0)