forked from BorealBaguette/Trainlog
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
44 lines (34 loc) · 1.46 KB
/
Copy pathMakefile
File metadata and controls
44 lines (34 loc) · 1.46 KB
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
# Most useful actions in this file:
#
# * make start: starts all the docker containers
# * make start-db: starts the db container only, locally. Useful for running flask
# locally, outside of docker
# * make start-local: starts the app locally, outside of docker
# * make psql: starts a psql prompt, connected to the db container
# read the .env file to set up env vars
include .env
# start the app, dockerized
start:
docker compose up --build -d
# start the database only
start-db:
docker compose up trainlog_db -d
# start the app only, locally (non-docker)
start-local: start-db
env $(cat .env | xargs) POSTGRES_HOST=localhost FLASK_APP=app gunicorn --timeout 1000 --bind 0.0.0.0:5000 app:app --reload --access-logfile - --access-logformat '%(h)s %(r)s %(s)s'
# stop all containers
stop:
docker compose down
# show application logs
logs:
docker compose logs -f --tail 1000
# start psql connected to the app's db
psql:
docker compose exec trainlog_db psql -U ${POSTGRES_USER} ${POSTGRES_DB}
# refresh schema.sql
generate-schema-sql:
@echo "-- File generated automatically, do not modify by hand!" > src/sql/migrations/schema.sql
@echo "-- Use \`make generate-schema-sql\` instead" >> src/sql/migrations/schema.sql
docker compose exec trainlog_db pg_dump -U ${POSTGRES_USER} ${POSTGRES_DB} --schema-only >> src/sql/migrations/schema.sql
@echo "SET search_path TO DEFAULT;" >> src/sql/migrations/schema.sql
.PHONY: start start-db start-app stop psql generate-schema-sql