-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
82 lines (63 loc) · 2.03 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
##############
# ROOT SCRIPTS
#######################
### SQL DEVELOPMENT ###
#######################
# db configuration variables
DB_NAME=application
DB_USER=application
DB_PASSWORD=password
DB_NETWORK=localhost
DB_SERVER_NAME=application-sql-server
####################
### database targets
.PHONY: db-image db-start-server db-migrate-up db-terminate db-stop-server db-run
# start a local database, migrate up to the current migration
db-run: db-start-server wait db-migrate-up
# build docker images for database
db-image:
cd ./deployments/sql && docker build -t $(DB_SERVER_NAME) .
# start the local database server
db-start-server:
docker run --name $(DB_SERVER_NAME) -p 5432:5432 \
-e POSTGRES_DB=$(DB_NAME) \
-e POSTGRES_PASSWORD=$(DB_PASSWORD) \
-e POSTGRES_USER=$(DB_USER) \
-d $(DB_SERVER_NAME)
# run the db migration tool
db-migrate-up:
sqlx migrate run
db-migrate-down:
cd server && sqlx migrate revert
### Terminate - the whole db stack, it's configuration, and data
db-terminate: db-stop-server db-clean
# stop dev database
db-stop-server:
docker stop $(DB_SERVER_NAME)
## cleans volumn
db-clean:
docker rm $(DB_SERVER_NAME)
#####################
### Local development
.PHONY: development clean
# run `$ make development` to run the db, and server locally
# todo - add command to run the server
development: db-run watch-server
# nuke your local dev state, and start from scratch
clean: db-terminate
# deploy the database server, run migrations, generate local config, build server image, and run the server
# If your working on one of the front-end applications this is a good place to get the back-end system up and
# running. All you need is docker on your local system.
##################
### server targets
.PHONY: watch-server
# use cargo watch to reload the server when changes have been made
watch-server:
cd server && \
export RUST_LOG=info PORT=8080 && \
cargo watch -x 'run --bin server server'
##################
### client targets
.PHONY: watch-client
watch-client:
cd dashboard && trunk serve --address=0.0.0.0