-
Notifications
You must be signed in to change notification settings - Fork 18
/
Makefile
90 lines (65 loc) · 2.16 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
87
88
89
90
VIRTUAL_ENV?=venv
PIP=$(VIRTUAL_ENV)/bin/pip
PIP_COMPILE=$(VIRTUAL_ENV)/bin/pip-compile
PYTHON_MAJOR_VERSION=3
PYTHON_MINOR_VERSION=9
PYTHON_VERSION=$(PYTHON_MAJOR_VERSION).$(PYTHON_MINOR_VERSION)
PYTHON_WITH_VERSION=python$(PYTHON_VERSION)
PYTHON=$(VIRTUAL_ENV)/bin/python
ISORT=$(VIRTUAL_ENV)/bin/isort
FLAKE8=$(VIRTUAL_ENV)/bin/flake8
BLACK=$(VIRTUAL_ENV)/bin/black
PYTEST=$(VIRTUAL_ENV)/bin/pytest
GUNICORN=$(VIRTUAL_ENV)/bin/gunicorn
DOCKER_IMAGE=andremiras/gitpop2
PORT?=8000
SOURCES=gitpop2/ tests/
ifndef CI
DOCKER_IT=-it
endif
all: virtualenv
$(VIRTUAL_ENV):
$(PYTHON_WITH_VERSION) -m venv $(VIRTUAL_ENV)
$(PYTHON) -m pip install --upgrade pip setuptools
virtualenv: $(VIRTUAL_ENV)
$(PIP) install --requirement requirements.txt
requirements.txt: | $(VIRTUAL_ENV)
$(PYTHON) -m pip install --upgrade pip-tools
$(PIP_COMPILE) --upgrade --output-file requirements.txt requirements.in
clean:
rm -rf venv/ .pytest_cache/
unittest: virtualenv
$(PYTEST) tests/
lint/isort: virtualenv
$(ISORT) --check-only --diff $(SOURCES)
lint/flake8: virtualenv
$(FLAKE8) $(SOURCES)
lint/black: virtualenv
$(BLACK) --check $(SOURCES)
lint: lint/isort lint/flake8 lint/black
format/isort: virtualenv
$(ISORT) $(SOURCES)
format/black: virtualenv
$(BLACK) $(SOURCES)
format: format/isort format/black
test: unittest lint
run/collectstatic: virtualenv
$(PYTHON) manage.py collectstatic --noinput
run/migrate: virtualenv
$(PYTHON) manage.py migrate --noinput
run/dev: virtualenv
$(PYTHON) manage.py runserver
run/gunicorn: virtualenv
$(GUNICORN) gitpop2.wsgi:application --bind 0.0.0.0:$(PORT)
docker/build:
docker build --tag=$(DOCKER_IMAGE) .
docker/run/make/%:
docker run --env-file .env.example $(DOCKER_IT) --rm $(DOCKER_IMAGE) make $*
docker/run/test: docker/run/make/test
docker/run/app:
docker run --env-file .env.example --env PORT=$(PORT) --publish $(PORT):$(PORT) $(DOCKER_IT) --rm $(DOCKER_IMAGE)
docker/run/app/production:
PRODUCTION=1 DJANGO_SECRET_KEY=1 \
docker run --env-file .env.example --env PORT=$(PORT) --publish $(PORT):$(PORT) $(DOCKER_IT) --rm $(DOCKER_IMAGE)
docker/run/shell:
docker run --env-file .env.example $(DOCKER_IT) --rm $(DOCKER_IMAGE) /bin/bash