-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
76 lines (57 loc) · 1.65 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
## ----- Variables -----
ENV = 1 # 0 for production, 1 for development
DB_VOL_NAME = postgres.data
STACK_NAME = $(shell basename $$PWD)
## Use git-secret.
SECRETS = true
## ----- Commands (targets) -----
.PHONY: default setup
## Default target when no arguments are given to make (run the program).
default: run
## Sets up this project on a new device.
setup: setup-hooks install
@if [ "$(SECRETS)" == true ]; then $(REVEAL_SECRETS_CMD); fi
## [Git setup / configuration commands]
.PHONY: setup-hooks hide-secrets reveal-secrets
## Configure Git to use .githooks (for shared githooks).
setup-hooks:
@echo "Configuring githooks..."
@git config core.hooksPath .githooks && echo "done"
## Initialize git-secret
init-secrets:
@git secret init
## Hide modified secret files using git-secret.
hide-secrets:
@echo "Hiding modified secret files..."
@git secret hide -m
## Reveal files hidden by git-secret.
REVEAL_SECRETS_CMD = git secret reveal
reveal-secrets:
@echo "Revealing secret files..."
@$(REVEAL_SECRETS_CMD)
## [Python commands]
.PHONY: dev-run install prod-init prod-update prod-run
## FLSK starts the flask server.
FLSK = pipenv run flask run
dev-run:
@echo "Starting Flask server ($(ENV))..."
@if [ "$(ENV)" -eq 1 ]; then \
export FLASK_ENV=development && export FLASK_DEBUG=1 && \
$(FLSK); \
else \
export FLASK_ENV=production && $(FLSK); \
fi
install:
@echo "Installing dependencies using 'pipenv'..."
@pipenv install --dev
prod-init:
@flask db init
@flask db migrate
@flask db upgrade
@scripts/prod_execute.sh
prod-update:
@flask db migrate
@flask db upgrade
@scripts/prod_execute.sh
prod-run:
@scripts/prod_execute.sh