-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
78 lines (66 loc) · 1.97 KB
/
Copy pathMakefile
File metadata and controls
78 lines (66 loc) · 1.97 KB
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
# Builds the dependencies packaged as a docker image
# Assumes docker is installed. If not, go to: https://www.docker.com/products/overview
# #
# * * * environment * * * #
# #
DOCKER := $(shell command -v docker 2> /dev/null)
VERSION := $(shell git rev-parse HEAD | tr -d '\n'; git diff-index -w --quiet HEAD -- || echo "-SNAPSHOT")
DOCKER_REGISTRY := hub.docker.com
DOCKER_REPO := repo
DOCKER_NAME := app
DOCKER_TAG := $(DOCKER_REGISTRY)/$(DOCKER_REPO)/$(DOCKER_NAME):$(VERSION)
DOCKER_TAG_LATEST := $(DOCKER_REGISTRY)/$(DOCKER_REPO)/$(DOCKER_NAME):latest
.PHONY: deps
deps:
ifndef DOCKER
$(error 'docker' binary is not found; please install Docker, as the app is containerized for portability)
endif
.PHONY: envvars
envvars:
ifndef DOCKER_NAME
$(error 'DOCKER_NAME' environment variable is undefined)
endif
ifndef DOCKER_REGISTRY
$(error 'DOCKER_REGISTRY' environment variable is undefined)
endif
ifndef DOCKER_REPO
$(error 'DOCKER_REPO' environment variable is undefined)
endif
ifndef VERSION
$(error 'VERSION' environment variable is undefined)
endif
# #
# * * * help * * * #
# #
.PHONY: help
help:
@echo
@echo ' make build - build the docker image tagged with the latest commit hash'
@echo ' make shell - open a shell in the container locally'
@echo
# #
# * * * targets * * * #
# #
.PHONY: build
build: deps envvars
docker build \
-t $(DOCKER_TAG) \
-t $(DOCKER_TAG_LATEST) \
-f docker/Dockerfile .
.PHONY: notebook
notebook: deps envvars stop build
docker run \
-p 8888:8888 \
-v $(PWD)/src:/app/src \
-it $(DOCKER_TAG_LATEST) \
jupyter notebook --ip=0.0.0.0 --port=8888
.PHONY: shell
shell: deps envvars stop build
docker run \
-v $(PWD)/src:/app/src \
-it $(DOCKER_TAG_LATEST) \
/bin/bash
.PHONY: stop
stop: deps envvars
docker stop $(DOCKER_NAME) 2> /dev/null || true
docker rm $(DOCKER_NAME) 2> /dev/null || true