-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
80 lines (66 loc) · 1.71 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
-include .env
# target: createdb - Create the initial DB
.PHONY: createdb
createdb:
docker exec -it stock_service_db createdb -U postgres stock_service
# target: createsuperuser - Create a super user account
.PHONY: createsuperuser
createsuperuser:
./manage.py createsuperuser
# target: deps - Install project dependencies
.PHONY: deps
deps:
pip install --upgrade pip
pip install -r requirements.txt
# target: makemigrations - Create migration files
.PHONY: makemigrations
makemigrations:
./manage.py makemigrations
# target: migrate - Execute the migrations
# and migrate database models
.PHONY: migrate
migrate:
./manage.py migrate
# target: removedb -Remove the database container and
# its data volume
.PHONY: removedb
removedb: stopdb
docker volume rm stock_service_data
# target: reset_db - Reset the database
.PHONY: reset_db
reset_db:
./manage.py reset_db
# target: reset_schema - Reset the database schema
.PHONY: reset_schema
reset_schema:
./manage.py reset_schema
# target: setup - Install the pre-commit requirement
.PHONY: setup
setup:
pre-commit install
# target: start - Run server (Default)
.PHONY: start
start:
./manage.py runserver
# target: startdb - Start the database container
.PHONY: startdb
startdb:
docker run -d --name stock_service_db \
-v stock_service_data:/var/lib/postgresql/data \
-p 5432:5432 \
-e POSTGRES_HOST_AUTH_METHOD=trust \
postgres:12
# target: stopdb - Stop the database container
.PHONY: stopdb
stopdb:
docker stop stock_service_db
docker rm stock_service_db
# target: schema - Create/Update the graphql schema file "data/schema.graphql"
.PHONY: schema
schema:
python manage.py graphql_schema
# Tests
# target: test - Run tests
.PHONY: test
test:
pytest