forked from fernandohenriques/nestjs-graphql-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
61 lines (52 loc) · 1.55 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
variables ?= .env
args = $(filter-out $@,$(MAKECMDGOALS))
include $(variables)
export $(shell sed 's/=.*//' $(variables))
build:
docker build \
-f ./docker/Dockerfile \
-t $(APP_NAME) \
--build-arg NODE_ENV=$(NODE_ENV) \
--build-arg PORT=$(PORT) \
.
run:
docker run -d -i \
--env-file $(variables) \
--name $(APP_NAME) \
-p $(PORT):$(PORT) \
$(APP_NAME)
up: build run
stop:
docker stop $(MONGO_HOST) || true; docker rm $(MONGO_HOST) || true
docker stop $(APP_NAME) || true; docker rm $(APP_NAME) || true
test: stop build
docker run -d -i \
--name $(MONGO_HOST) \
-e "MONGO_INITDB_DATABASE=$(MONGO_DATABASE_NAME)" \
-e "MONGO_INITDB_ROOT_USERNAME=$(MONGO_USERNAME)" \
-e "MONGO_INITDB_ROOT_PASSWORD=$(MONGO_PASSWORD)" \
-p $(MONGO_PORT):$(MONGO_PORT) \
-v "$(PWD)/docker/init-mongo.sh:/docker-entrypoint-initdb.d/init-mongo.sh" \
mongo:latest
ifeq ($(NODE_ENV),development)
docker run -i -t \
--env-file $(variables) \
--name $(APP_NAME) \
--link $(MONGO_HOST):$(MONGO_HOST) \
$(APP_NAME) \
/bin/sh -c "npm run test && npm run test:e2e && npm run test:graphql"
else
docker run -d -i \
--env-file $(variables) \
--name $(APP_NAME) \
--link $(MONGO_HOST):$(MONGO_HOST) \
$(APP_NAME) \
/bin/sh -c "npm run test && npm run test:e2e && npm run test:graphql"
endif
# DEVELOPMENT TASKS
install:
npm install $(args) --save
docker exec -it $(APP_NAME) npm install $(args) --save
uninstall:
npm uninstall $(args) --save
docker exec -it $(APP_NAME) npm uninstall $(args) --save