This repository has been archived by the owner on Nov 22, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
102 lines (74 loc) · 3.44 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
.PHONY: install start stop
CURRENT_UID=$(shell id -u):$(shell id -g)
export CURRENT_UID
export NODE_ENV ?= development
DC_DEV := docker-compose -p usine-distribuee
DOCKER_ADMIN := docker run --rm -v ${PWD}/apps/admin:/admin -u=${CURRENT_UID} -w /admin node:13.11.0
DOCKER := docker run --rm -v ${PWD}:/application -u=${CURRENT_UID} -w /application node:13.11.0
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
@${DC_DEV} run --rm --no-deps api bash -ci 'yarn'
@${DC_DEV} run --rm --no-deps admin bash -ci 'yarn'
@${DOCKER} yarn
# =====================================================================
# Operating recipies ==================================================
# =====================================================================
start: ## Start all service in containers
${DC_DEV} up -d
stop: ## Stop all containers
${DC_DEV} down
logs: ## Display all logs
${DC_DEV} logs -f
logs-api: ## Display api logs
${DC_DEV} logs -f api
logs-db: ## Display postgres logs
${DC_DEV} logs -f postgres
logs-admin: ## Display admin logs
${DC_DEV} logs -f admin
connect-api: ## Start cli in api container
${DC_DEV} exec api bash
connect-admin: ## Start cli in admin container
${DC_DEV} exec admin bash
# =====================================================================
# DATABASE ============================================================
# =====================================================================
migrate-create: ## Create a new migration file, ie make migrate-create name=whatever-title
$(DC_DEV) exec api bash -ci 'yarn migrate:create -- ${name}'
migrate-latest: ## Apply Migrations up to the last one
$(DC_DEV) exec api bash -ci 'yarn migrate:latest'
migrate-rollback: ## Apply Migrations down to last state
$(DC_DEV) exec api bash -ci 'yarn migrate:rollback'
migrate-down: ## Apply Migrations down one step
$(DC_DEV) exec api bash -ci 'yarn migrate:down'
migrate-up: ## Apply Migrations up one step
$(DC_DEV) exec api bash -ci 'yarn migrate:up'
migrate-list: ## Apply Migrations list
$(DC_DEV) exec api bash -ci 'yarn migrate:list'
create-admin: ## Create a new administrator user_account in database
$(DC_DEV) exec api bash -ci 'node ./cli/create-admin.js'
# =====================================================================
# Linting ==============================================================
# =====================================================================
lint: ## Apply Eslint on code base
yarn lint
format: ## Apply Prettier on code base
yarn format
# =====================================================================
# Deploy ==============================================================
# =====================================================================
prepare-deploy: ## Prepare app for production
${DOCKER_ADMIN} yarn build
rm -rf apps/api/admin
mkdir -p apps/api/admin
cp -R apps/admin/build/* apps/api/admin/
clever-cloud-build: ## Post build step on Clever Cloud
cd apps/admin && yarn install
cd apps/api && yarn install
cd apps/admin && yarn build
rm -rf apps/api/admin
mkdir -p apps/api/admin
cp -R apps/admin/build/* apps/api/admin/