-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
106 lines (86 loc) · 3.23 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
BACKEND_START_CMD=gunicorn api.app:app --workers=2 --worker-class=uvicorn.workers.UvicornWorker --bind=0.0.0.0:8000 --access-logfile -
DOCKER_START_CMD_BASE=docker run -d --rm --network engage-network
.PHONY: up
up:
docker compose up --build
.PHONY: alembic-revision
alembic-revision:
docker compose exec api sh -c "python -m alembic revision -m \"$(m)\" --autogenerate --rev-id \"$(rev-id)\""
.PHONY: alembic-upgrade
alembic-upgrade:
docker compose exec api sh -c "python -m alembic upgrade head"
.PHONY: alembic-downgrade
alembic-downgrade:
docker compose exec api sh -c "python -m alembic downgrade -1"
.PHONY: adduser
adduser:
docker compose exec api sh -c "python cli.py adduser $(params)"
.PHONY: test-backend
test-backend:
cd backend && poetry run pytest -v
.PHONY: test-backend-w-db
test-backend-w-db:
cd backend && ENGAGE_BACKEND_TESTS__TEST_DATABASE=true ENGAGE_BACKEND_DATABASE__HOST=localhost poetry run pytest -v
.PHONY: start-test-db
start-test-db:
docker compose up -d database
.PHONY: stop-test-db
stop-test-db:
docker compose down
.PHONY: lint
lint:
cd backend && poetry run pre-commit run -c ../.pre-commit-config.yaml
.PHONY: lint-all
lint-all:
cd backend && poetry run pre-commit run -c ../.pre-commit-config.yaml --all-files
.PHONY: build-dev-frontend-backend
build-dev-frontend-backend:
docker build --build-arg ENVIRONMENT=PRODUCTION -t engage-api ./backend
docker build -t engage-client ./frontend
.PHONY: create-engage-network
create-engage-network:
(test -z $$(docker network ls --filter name=engage-network -q) \
&& (docker network create engage-network \
|| echo "Creating engage-network docker network failed.")) \
|| echo "engage-network already exists"
.PHONY: start-dev-frontend-backend
start-dev-frontend-backend: create-engage-network
${DOCKER_START_CMD_BASE} \
--network-alias api \
--name engage-api \
--env-file .env.dev \
--publish 8000:8000 \
engage-api:latest sh -c '${BACKEND_START_CMD}' \
|| echo "Starting engange-api failed."
${DOCKER_START_CMD_BASE} \
--network-alias client \
--name engage-client \
--publish 8080:80 \
engage-client:latest \
|| echo "Starting engange-client failed."
.PHONY: build-and-start-dev-frontend-backend
build-and-start-dev-frontend-backend:
make build-dev-frontend-backend
make start-dev-frontend-backend
.PHONY: start-dev-database
start-dev-database: create-engage-network
${DOCKER_START_CMD_BASE} \
--network-alias database \
--name engage-database \
--env-file .env.dev \
postgres:13.2 \
|| echo "Starting engange-database failed."
.PHONY: stop-engage-dev-frontend-backend
stop-engage-dev-frontend-backend:
docker stop engage-api || echo "Stopping engage-api failed."
docker stop engage-client || echo "Stopping engage-client failed."
docker network rm engage-network || echo "Removing engage-network docker network failed."
.PHONY: run-local-db-upgrade
run-local-db-upgrade:
cd backend/src && ENGAGE_BACKEND_DATABASE__HOST=localhost poetry run alembic upgrade head
.PHONY: create-local-test-user
create-local-test-user:
cd backend && ENGAGE_BACKEND_DATABASE__HOST=localhost poetry run python src/cli.py adduser
.PHONY: start-local-backend
start-local-backend:
cd backend && ENGAGE_BACKEND_DATABASE__HOST=localhost poetry run python src/main.py