-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
96 lines (82 loc) · 3.21 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
.PHONY: lint build clean build_docker dev run docs
################################################################################
# DEVELOP
#
# make dev_app APP=<app_name>
#
################################################################################
dev_app:
NODE_ENV=development \
APP=$(APP) \
TS_NODE_TRANSPILE_ONLY=true \
yarn nodemon --exec \
yarn env-cmd --no-override -f ./env/.env yarn env-cmd --no-override -f ./env/$(APP).env yarn ts-node -r tsconfig-paths/register src/apps/$(APP)/main.ts | yarn pino-pretty -c -t -l
dev_app_debug:
NODE_ENV=development \
APP=$(APP) \
yarn env-cmd --no-override -f ./env/.env yarn env-cmd --no-override -f ./env/$(APP).env yarn nest start $(APP) --debug --watch | yarn pino-pretty -c -t
################################################################################
# BUILD
################################################################################
build: clean
yarn run build && \
cp ormconfig.js dist/ && \
cp package.json dist/ && \
mkdir -p dist/data
cp data/* dist/data && \
cp yarn.lock dist/ && \
cp tsconfig.json dist/ && \
for filename in $$(find . -iname '*.json' -a | grep -v '^./dist' | grep -v '^./node_modules' | sed 's/^..//'); do mkdir -p "./dist/$$(dirname $$filename)" && cp $$filename "./dist/$$filename"; done && \
cd dist && \
NODE_ENV=${NODE_ENV:-production} yarn
build_docker:
docker build -t skelleton:latest --build-arg APP="$(APP)" --cache-from $$IMAGE_REGISTRY . -q
build_docker_local:
docker build -t skelleton:latest --build-arg APP="$(APP)" . -q
build_docker_gitlab:
docker pull $$IMAGE_REGISTRY && \
docker build -t $$IMAGE_REGISTRY --cache-from $$IMAGE_REGISTRY . -q && \
docker push $$IMAGE_REGISTRY \
################################################################################
# MIGRATE
#
# make migrate_up [DOCKER=1]
# make migrate_down [DOCKER=1]
# make migrate_down_all [DOCKER=1]
# make migrate_generate NAME=<migration-file-name>
# make migrate_create NAME=<migration-file-name>
# make migrate_generate_initial
#
################################################################################
migrate_generate:
$(MAKE) typeorm_cmd COMMAND="migration:generate -n $(NAME)"
migrate_create:
$(MAKE) typeorm_cmd COMMAND="migration:create -n $(NAME)"
migrate_up:
@if [[ -z "${DOCKER}" ]]; then \
$(MAKE) typeorm_cmd COMMAND=migration:run; \
else \
docker-compose run --name migrator --rm api make migrate_up; \
fi;
migrate_down:
@if [[ -z "${DOCKER}" ]]; then \
$(MAKE) typeorm_cmd COMMAND=migration:revert; >> '/dev/null' \
else \
docker-compose run --name migrator --rm api make migrate_down; \
fi;
migrate_down_all:
@if [[ -z "${DOCKER}" ]]; then \
$(MAKE) typeorm_cmd COMMAND=schema:drop; >> '/dev/null' \
else \
docker-compose run --name migrator --rm api make migrate_down_all; \
fi;
migrate_reset_database:
$(MAKE) migrate_down_all && \
$(MAKE) migrate_up
typeorm_cmd:
APP=api yarn ts-node -r tsconfig-paths/register $$(yarn bin)/typeorm $(COMMAND)
################################################################################
# OTHER
################################################################################
clean:
rm -rf dist