-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathMakefile
106 lines (81 loc) · 3.73 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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
help:
@echo 'Makefile for managing web application '
@echo ' '
@echo 'Usage: '
@echo ' make build build images '
@echo ' make up creates containers and starts service '
@echo ' make start starts service containers '
@echo ' make stop stops service containers '
@echo ' make down stops service and removes containers '
@echo ' '
@echo ' make migration create migration m="message" '
@echo ' make migrate-up run all migration '
@echo ' make migrate-dow roll back last migration '
@echo ' make test run tests '
@echo ' make test-cov run tests with coverage.py '
@echo ' make test-fast run tests without migrations '
@echo ' make lint run flake8 linter '
@echo ' '
@echo ' make attach attach to process inside service '
@echo ' make logs see container logs '
@echo ' make shell connect to api container in new bash shell '
@echo ' make shell-ipython connect to api container in new bash shell '
@echo ' make shell-db shell into psql inside database container '
@echo ' make view-dash view task queue dashboardd '
@echo ' '
build:
docker-compose build
up:
docker-compose up -d
make migrate-up
start:
docker-compose start
stop:
docker-compose stop
down:
docker-compose down
attach: ## Attach to web container
docker attach `docker-compose ps -q api`
attach-worker:
docker attach `docker-compose ps -q worker`
logs:
docker logs `docker-compose ps -q api`
shell: ## Shell into web container
docker-compose exec api bash
shell-db: ## Shell into postgres process inside db container
docker-compose exec db psql -w --username "sivdev_user" --dbname "sivdev"
shell-ipython: ## Shell into ipython with falcon context
docker-compose exec api python /app/scripts/ipython_shell.py
shell-profiler:
docker-compose exec profiler bash
shell-root: # Shell into web container as root
docker-compose exec -u root api bash
migration: ## Create migration
docker-compose exec api alembic --config=./migrations/alembic.ini revision --autogenerate -m "$(m)"
migrate-up: ## Run migrations
docker-compose exec api alembic --config=./migrations/alembic.ini upgrade head
migrate-down: ## Rollback migration
docker-compose exec api alembic --config=./migrations/alembic.ini downgrade -1
test: migrate-up ## run tests
docker-compose exec api pytest $(args)
test_fast:
docker-compose exec api pytest
test-cov: migrate-up
docker-compose exec api pytest --verbose --cov
test-cov-view: migrate-up
docker-compose exec api pytest --cov --cov-report html && open ./htmlcov/index.html
test-fast: ## Can pass in parameters using p=''
docker-compose exec api pytest $(p)
bandit: # static analyzer for common security issues
docker-compose exec api bandit -r app
view-dash:
open http://0.0.0.0:9181/
# Flake 8
# options: http://flake8.pycqa.org/en/latest/user/options.html
# codes: http://flake8.pycqa.org/en/latest/user/error-codes.html
max_line_length = 99
lint: up
docker-compose exec api flake8 \
--max-line-length $(max_line_length)
mypy:
docker-compose exec api mypy .