-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
49 lines (38 loc) · 905 Bytes
/
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
PROJ := dockertom
VENV := tom_env
DB_PATH := storage
C_APP := docker
GIT_DIRTY := $(shell git status --porcelain)
GIT_TAG := $(shell git describe --always)
# Add a suffix to the tag if the repo is dirty
ifeq ($(GIT_DIRTY),)
TAG := $(GIT_TAG)
else
TAG := $(GIT_TAG)-dirty
endif
all: run
# Build Docker image
build:
$(C_APP) build --tag $(PROJ):$(TAG) .
# Create Python virtual environment
venv:
python3 -m venv $(VENV)
# Install Python dependencies to the virtual environment
deps: venv
. $(VENV)/bin/activate && \
pip install --requirement requirements.txt
# Migrate the Django database
migrate: deps
[[ -d $(DB_PATH) ]] || mkdir $(DB_PATH)
. $(VENV)/bin/activate && \
./manage.py migrate
# Run the Docker image
run: migrate build
$(C_APP) run \
--interactive \
--tty \
--rm \
--name $(PROJ) \
--publish 8080:8080 \
--volume ${PWD}/storage:/tom/storage \
$(PROJ):$(TAG)