This repository has been archived by the owner on Aug 13, 2021. It is now read-only.
generated from IllumiDesk/docker-stacks
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
86 lines (68 loc) · 2.89 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# inspiration from https://github.com/jupyter/docker-stacks
.PHONY: build
# Use bash for inline if-statements in target
SHELL:=bash
TAG:=latest
OWNER:=illumidesk
VENV_NAME?=venv
VENV_BIN=$(shell pwd)/${VENV_NAME}/bin
VENV_ACTIVATE=. ${VENV_BIN}/activate
PYTHON=${VENV_BIN}/python3
# Need to list the images in build dependency order
ALL_STACKS:=base-workspace \
vscode-workspace \
grader-workspace
ALL_IMAGES:=$(ALL_STACKS)
# Linter
HADOLINT="${HOME}/hadolint"
help:
# http://marmelab.com/blog/2016/02/29/auto-documented-makefile.html
# http://github.com/jupyter/docker-stacks
@echo "illumidesk/skkgsb-stacks"
@echo "====================="
@echo "Replace % with a stack directory name (e.g., make build/illumidesk-notebook)"
@echo
@grep -E '^[a-zA-Z0-9_%/-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
build/%: DARGS?=
build/%: TAG?=
build/%: ## build the latest image for a stack
${VENV_BIN}/jupyter-repo2docker --no-run --user-id 1000 --user-name jovyan --image-name $(OWNER)/$(notdir $@):$(TAG) ./$(notdir $@) .
@echo -n "Built image size: "
@docker images $(OWNER)/$(notdir $@):$(TAG) --format "{{.Size}}"
build-all: $(foreach I,$(ALL_IMAGES), build/$(I)) ## build all stack
push/%: DARGS?=
push/%: TAG?=
push/%: ## push stack images
@docker push $(OWNER)/$(notdir $@):$(TAG)
push-all: $(foreach I,$(ALL_IMAGES), push/$(I)) ## push all stacks
clean-all: ## clean all docker containers
@docker rm -f $(docker ps -aq)
dev/%: ARGS?=
dev/%: DARGS?=
dev/%: PORT?=8888
dev/%: ## run one of the containers (stacks) on port 8888
docker run -it --rm -p $(PORT):8888 $(DARGS) $(OWNER)/$(notdir $@) $(ARGS)
lint/%: ARGS?=--config .hadolint.yml
lint/%: ## lint the dockerfile(s) for a stack
@echo "Linting Dockerfiles with Hadolint in $(notdir $@)..."
@git ls-files --exclude='Dockerfile*' --ignored $(notdir $@) | grep -v ppc64 | xargs -L 1 $(HADOLINT) $(ARGS)
@echo "Linting with Hadolint done!"
@echo "Linting tests with flake8 in in $(notdir $@)..."
${VENV_BIN}/flake8 $(notdir $@)
@echo "Linting with flake8 done!"
@echo "Applying black updates to test files in $(notdir $@)..."
${VENV_BIN}/black $(notdir $@)
@echo "Source formatting with black done!"
lint-all: $(foreach I,$(ALL_IMAGES),lint/$(I) ) ## lint all stacks
lint-build-all: $(foreach I,$(ALL_IMAGES),lint/$(I) build/$(I) ) ## lint, build and test all stacks
lint-install: ## install hadolint
@echo "Installing hadolint at $(HADOLINT) ..."
@curl -sL -o $(HADOLINT) "https://github.com/hadolint/hadolint/releases/download/v1.18.0/hadolint-$(shell uname -s)-$(shell uname -m)"
@chmod 700 $(HADOLINT)
@echo "Hadolint nstallation done!"
@$(HADOLINT) --version
test: ## test images as running containers
${VENV_BIN}/pytest -v
venv: ## install hadolint create virtual environment
test -d $(VENV_NAME) || virtualenv -p python3 $(VENV_NAME)
${PYTHON} -m pip install -r dev-requirements.txt