-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathMakefile
72 lines (57 loc) · 1.66 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
ENV_FILE = $(shell pwd)$(shell echo '/core/.env')
include $(ENV_FILE)
export $(shell sed 's/=.*//' `pwd`/core/.env)
_DEVELOPMENT_DATABASE_URI=$(DEVELOPMENT_DATABASE_URI)
_TEST_DATABASE_URI=$(TEST_DATABASE_URI)
.PHONY: clear run-server run-tests help dcompose-start dcompose-start dcompose-stop dcleanup
clear:
@find . -name __pycache__ -prune -exec rm -rf {} +
@find . -name "*.pyc" -prune -exec rm -rf {} +
@find . -name .cache -prune -exec rm -rf {} +
db-revision:
@(\
cd core/migrations && alembic revision --autogenerate -m "$(msg)"; \
)
db-upgrade:
$(shell cd core/migrations && alembic upgrade head)
db-upgrade-sql:
@(\
cd core/migrations && alembic upgrade head --sql; \
)
dcompose-start:
@docker-compose stop;
@docker-compose build;
@docker-compose up -d;
dcompose-restart:
@docker-compose stop;
@docker-compose build;
@docker-compose up -d;
dcompose-stop:
@docker-compose stop
dcleanup:
@docker rm $(shell docker ps -qa --no-trunc --filter "status=exited")
@docker rmi $(shell docker images --filter "dangling=true" -q --no-trunc)
run-server:
@(\
export SQLALCHEMY_DATABASE_URI=$(_DEVELOPMENT_DATABASE_URI); \
python ./core/run.py; \
)
run-tests: clear
@(\
export SQLALCHEMY_DATABASE_URI=$(_TEST_DATABASE_URI); \
pytest -s; \
)
help:
@echo 'dcompose-start:'
@echo ' Build and start containers'
@echo 'dcompose-stop:'
@echo ' Stop running containers'
@echo 'dcleanup:'
@echo ' Remove docker containers with status `exited`'
@echo ' Remove unused docker images'
@echo 'run-server:'
@echo ' Start application server'
@echo 'run-tests:'
@echo ' Run tests'
@echo 'clear':
@echo ' Remove *.pyc files, __pycache__ and .cache folders'