-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
90 lines (62 loc) · 1.93 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
AUTO_FIX_IMPORTS ?= 0
CXML_TESTER_RELEASE = 1.0.3
PORT ?= 8080
ifneq ($(AUTO_FIX_IMPORTS), 1)
autofix = --check-only
endif
test: static unit
init: pipenv-init pipenv-sync
pipenv-init:
pip3 install --upgrade pip
pip install pipenv
pipenv-sync:
pipenv sync --dev
unit:
pipenv run python -m pytest
static: imports flake8 pylint
flake8:
pipenv run flake8 p6t util tests
pylint:
pipenv run pylint p6t util tests -E
imports:
pipenv run isort $(autofix) p6t util tests
test-clean:
rm -f tests/*.sqlite
export RUN_MODE = development
run-flask:
pipenv run python -m flask run --host=0.0.0.0 --port=$(PORT)
run:
pipenv run gunicorn --bind :$(PORT) --workers 1 --threads 8 --timeout 0 p6t:app
run-prod:
$(MAKE) run RUN_MODE=production
DOCKER_IMG_TAG = cxml-tester
DOCKER_IMG_VERSION = v$(CXML_TESTER_RELEASE)
docker:
pipenv requirements > requirements.txt
docker build -t $(DOCKER_IMG_TAG):$(DOCKER_IMG_VERSION) .
ifeq ($(DOCKER_PUSH),1)
docker push $(DOCKER_IMG_TAG):$(DOCKER_IMG_VERSION)
endif
########################## docker run commands ##################################
docker-test: DOCKER_IMG_TEST_NAME = cxml-tester
docker-test:
-docker rm -f $(DOCKER_IMG_TEST_NAME)
docker run --rm --name $(DOCKER_IMG_TEST_NAME) $(DOCKER_IMG_TAG):$(DOCKER_IMG_VERSION) bash -c 'pipenv sync --dev; make test'
docker-flask-dev:
docker run --network="host" -it --rm --name flask-dev \
$(DOCKER_IMG_TAG):$(DOCKER_IMG_VERSION) \
make run-flask $(DOCKER_RUN_ARGS)
DOCKER_SERVICE_INSTALL = 0
ifeq ($(DOCKER_SERVICE_INSTALL),1)
DOCKER_RUN_ARGS = -dit --restart always
else
DOCKER_RUN_ARGS = -it --rm
endif
# make -n docker-flask-prod DOCKER_SERVICE_INSTALL=1
docker-flask-prod:
docker pull $(DOCKER_IMG_TAG)
docker run $(DOCKER_RUN_ARGS) -p 8080:8080 --name flask-prod $(DOCKER_IMG_TAG):$(DOCKER_IMG_VERSION) make run-flask-prod $(DOCKER_RUN_EXTRA_ARGS)
git-tag:
git tag $(CXML_TESTER_RELEASE)
git push origin $(CXML_TESTER_RELEASE)
.PHONY: docker