-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmakefile
48 lines (41 loc) · 1.35 KB
/
makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
IMAGE_NAME := $(shell basename `git rev-parse --show-toplevel` | tr '[:upper:]' '[:lower:]')
GIT_TAG ?= $(shell git log --oneline | head -n1 | awk '{print $$1}')
DOCKER_REGISTRY := mathematiguy
IMAGE := $(DOCKER_REGISTRY)/$(IMAGE_NAME)
HAS_DOCKER ?= $(shell which docker)
RUN ?= $(if $(HAS_DOCKER), docker run $(DOCKER_ARGS) --rm -v $$(pwd):/work -w /work -u $(UID):$(GID) $(IMAGE))
UID ?= $(shell id -u)
GID ?= $(shell id -g)
DOCKER_ARGS ?=
.PHONY: docker docker-push docker-pull enter enter-root
JUPYTER_PASSWORD ?= jupyter
JUPYTER_PORT ?= 8888
.PHONY: jupyter
jupyter: UID=root
jupyter: GID=root
jupyter: DOCKER_ARGS=-u $(UID):$(GID) --rm -it -p $(JUPYTER_PORT):$(JUPYTER_PORT) -e NB_USER=$$USER -e NB_UID=$(UID) -e NB_GID=$(GID)
jupyter:
$(RUN) jupyter lab \
--allow-root \
--port $(JUPYTER_PORT) \
--ip 0.0.0.0 \
--NotebookApp.password=$(shell $(RUN) \
python3 -c \
"from IPython.lib import passwd; print(passwd('$(JUPYTER_PASSWORD)'))")
docker:
docker build $(DOCKER_ARGS) --tag $(IMAGE):$(GIT_TAG) .
docker tag $(IMAGE):$(GIT_TAG) $(IMAGE):latest
docker-push:
docker push $(IMAGE):$(GIT_TAG)
docker push $(IMAGE):latest
docker-pull:
docker pull $(IMAGE):$(GIT_TAG)
docker tag $(IMAGE):$(GIT_TAG) $(IMAGE):latest
enter: DOCKER_ARGS=-it
enter:
$(RUN) bash
enter-root: DOCKER_ARGS=-it
enter-root: UID=root
enter-root: GID=root
enter-root:
$(RUN) bash