@@ -7,7 +7,8 @@ SHELL:=bash
77OWNER? =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
2021export DOCKER_BUILDKIT: =1
2122
23+
24+
2225# https://marmelab.com/blog/2016/02/29/auto-documented-makefile.html
2326help :
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+
3035build/% : DARGS?=
3136build/% : # # 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
3945check-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)
4552cont-stop-all : # # stop all containers
4653 @echo " Stopping all containers ..."
4754 -docker stop -t0 $(shell docker ps -a -q) 2> /dev/null
48-
4955cont-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+
5361dev/% : ARGS?=
5462dev/% : DARGS?=-e JUPYTER_ENABLE_LAB=yes
5563dev/% : PORT?=8888
@@ -59,48 +67,53 @@ dev/%: ## run a foreground container for a stack
5967dev-env : # # install libraries required to build docs and run tests
6068 @pip install -r requirements-dev.txt
6169
70+
71+
6272docs : # # build HTML documentation
6373 sphinx-build docs/ docs/_build/
6474
75+
76+
6577hook/% : WIKI_PATH?=../wiki
6678hook/% : # # 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
7486img-list : # # list jupyter images
7587 @echo " Listing $( OWNER) images ..."
7688 docker images " $( OWNER) /*"
77-
7889img-rm : # # remove jupyter images
7990 @echo " Removing $( OWNER) images ..."
8091 -docker rmi --force $(shell docker images --quiet "$(OWNER ) /* ") 2> /dev/null
81-
8292img-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+
8698pre-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-
89100pre-commit-install : # # set up the git hook scripts
90101 @pre-commit --version
91102 @pre-commit install
92103
104+
105+
93106pull/% : DARGS?=
94107pull/% : # # 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
99111push/% : DARGS?=
100112push/% : # # 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
105118run/% : DARGS?=
106119run/% : # # run a bash in interactive mode in a stack
@@ -110,8 +123,10 @@ run-sudo/%: DARGS?=
110123run-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+
113128test/% : # # 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
0 commit comments