forked from plaid/pattern
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
75 lines (63 loc) · 2.32 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
mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST)))
current_dir := $(notdir $(patsubst %/,%,$(dir $(mkfile_path))))
envfile := ./.env
clear_db_after_schema_change := database/last-cleared.dummy
db_schema := database/init/*
.PHONY: help start start-no-webhooks debug sql logs stop clear-db
# help target adapted from https://gist.github.com/prwhite/8168133#gistcomment-2278355
TARGET_MAX_CHAR_NUM=20
## Show help
help:
@echo ''
@echo 'Usage:'
@echo ' make <target>'
@echo ''
@echo 'Targets:'
@awk '/^[a-zA-Z_0-9-]+:/ { \
helpMessage = match(lastLine, /^## (.*)/); \
if (helpMessage) { \
helpCommand = substr($$1, 0, index($$1, ":")-1); \
helpMessage = substr(lastLine, RSTART + 3, RLENGTH); \
printf " %-$(TARGET_MAX_CHAR_NUM)s %s\n", helpCommand, helpMessage; \
} \
} \
{ lastLine = $$0 }' $(MAKEFILE_LIST)
## Start the services
start: $(envfile) $(clear_db_after_schema_change)
@echo "Pulling images from Docker Hub (this may take a few minutes)"
docker compose pull
@echo "Starting Docker services"
docker compose up --build --detach
./wait-for-client.sh
## Start the services without webhooks
start-no-webhooks: $(envfile) $(clear_db_after_schema_change)
@echo "Pulling images from Docker Hub (this may take a few minutes)"
docker compose pull
@echo "Starting Docker services"
docker compose up --detach client
./wait-for-client.sh
## Start the services in debug mode
debug: $(envfile) $(clear_db_after_schema_change)
@echo "Starting services (this may take a few minutes if there are any changes)"
docker compose -f docker-compose.yml -f docker-compose.debug.yml up --build --detach
./wait-for-client.sh
## Start an interactive psql session (services must running)
sql:
docker compose exec db psql -U postgres
## Show the service logs (services must be running)
logs:
docker compose logs --follow
## Stop the services
stop:
docker compose down
docker volume rm $(current_dir)_{client,server}_node_modules 2>/dev/null || true
## Clear the sandbox and development databases
clear-db: stop
docker volume rm $(current_dir)_pg_{sandbox,development}_data 2>/dev/null || true
$(envfile):
@echo "Error: .env file does not exist! See the README for instructions."
@exit 1
# Remove local DBs if the DB schema has changed
$(clear_db_after_schema_change): $(db_schema)
@$(MAKE) clear-db
@touch $(clear_db_after_schema_change)