-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
85 lines (62 loc) · 3.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
83
84
85
.PHONY: install start stop log
CURRENT_UID=$(id -u):$(id -g)
export CURRENT_UID ?= $(shell id -u):$(shell id -g)
export NODE_ENV ?= development
DOCKER := docker run --rm -v ${PWD}:/app -u=${CURRENT_UID} -w /app node:14-alpine
help: ## Display available commands
@fgrep -h "##" $(MAKEFILE_LIST) | fgrep -v fgrep | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
# =====================================================================
# Initialization ======================================================
# =====================================================================
install: ## Install all js deps
npm install
cd apps/admin && npm install
cd apps/api && npm install
# ==============================================================
# PM2 dev environment ==========================================
# ==============================================================
start: db-start ## start api and admin with pm2
PM2_HOME='.pm2' ./node_modules/.bin/pm2 start ecosystem.config.js
stop: db-stop ## stop api and admin
PM2_HOME='.pm2' ./node_modules/.bin/pm2 stop ecosystem.config.js
PM2_HOME='.pm2' ./node_modules/.bin/pm2 cleardump
logs: ## display pm2 logs of api and admin
PM2_HOME='.pm2' ./node_modules/.bin/pm2 logs
status: ## display pm2 list
PM2_HOME='.pm2' ./node_modules/.bin/pm2 ls
monit: ## display pm2 monitoring
PM2_HOME='.pm2' ./node_modules/.bin/pm2 dash
reset: ## reset pm2
PM2_HOME='.pm2' ./node_modules/.bin/pm2 cleardump
# ===============================================================
# Dockerized Database ===========================================
# ===============================================================
db-start: ## start PostgreSQL in Docker Compose
docker-compose up -d
db-stop: ## stop Docker Compose PG
docker-compose down
db-logs: ## Display pg logs from Docker Compose
docker-compose logs -f
db-init: ## Create dump and replace the last one. Environment must be started
docker-compose exec postgres bash -ci 'psql -U backend-local-user --file /db-init/initdb.sql cc_backend_db'
db-dump: ## Create dump and replace the last one. Environment must be started
docker-compose exec postgres bash -ci 'pg_dump -F c -U backend-local-user cc_backend_db > /db-dump/backend.dump'
# =====================================================================
# ADR - Architecture Decision Records =================================
# =====================================================================
adr-new: ## Create new ADR
@if [ "$(title)" = "" ]; then \
echo 'Vous devez déclarer un titre'; \
echo 'Exemple: make adr-new title="New Team Decision"'; \
exit 1; \
fi
@${DOCKER} yarn adr:new "${title}"
adr-list: ## List all ADR
@${DOCKER} yarn adr:list
# =====================================================================
# Build ===============================================================
# =====================================================================
build: ## Build the front
rm -rf apps/api/admin/*
cd apps/admin && npm run build
cp -R apps/admin/build/* apps/api/admin/