-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
80 lines (67 loc) · 2.15 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
# Project variables
PROJECT_NAME ?= wire
ORG_NAME ?= bench-projects
REPO_NAME ?= wire-api
# File names
DOCKER_DEV_COMPOSE_FILE := docker/dev/docker-compose.yml
DOCKER_REGISTRY ?= gcr.io
.PHONY: help
## Show help
help:
@echo ''
@echo 'Usage:'
@echo '${YELLOW} make ${RESET} ${GREEN}<target> [options]${RESET}'
@echo ''
@echo 'Targets:'
@awk '/^[a-zA-Z\-\_0-9]+:/ { \
message = match(lastLine, /^## (.*)/); \
if (message) { \
command = substr($$1, 0, index($$1, ":")-1); \
message = substr(lastLine, RSTART + 3, RLENGTH); \
printf " ${YELLOW}%-$(TARGET_MAX_CHAR_NUM)s${RESET} %s\n", command, message; \
} \
} \
{ lastLine = $$0 }' $(MAKEFILE_LIST)
@echo ''
## Start the development environment containers
start:
${INFO} "Creating postgres data volume"
@ docker volume create --name=data > /dev/null
${INFO} "Spinning up your development environment..."
@ echo " "
@ docker-compose -f $(DOCKER_DEV_COMPOSE_FILE) build
@ docker-compose -f $(DOCKER_DEV_COMPOSE_FILE) up
@ cd src && yarn install && npm run migrate-seed && npm run start:dev
@ ${INFO} "Your development environment is now ready"
## Stop development containers
stop:
${INFO} "Stopping your development environment containers..."
@ docker-compose -f $(DOCKER_DEV_COMPOSE_FILE) down -v
@ docker images -q -f dangling=true | xargs -I ARGS docker rmi -f ARGS
${INFO} "All containers stopped successfully"
# extract ssh arguments
ifeq (ssh,$(firstword $(MAKECMDGOALS)))
SSH_ARGS := $(word 2, $(MAKECMDGOALS))
ifeq ($(SSH_ARGS),)
$(error You must specify a service)
endif
$(eval $(SSH_ARGS):;@:)
endif
# extract ssh arguments
ifeq (tag,$(firstword $(MAKECMDGOALS)))
TAG_ARGS := $(word 2, $(MAKECMDGOALS))
ifeq ($(TAG_ARGS),)
$(error You must specify a tag)
endif
$(eval $(TAG_ARGS):;@:)
endif
# COLORS
GREEN := $(shell tput -Txterm setaf 2)
YELLOW := $(shell tput -Txterm setaf 3)
WHITE := $(shell tput -Txterm setaf 7)
NC := "\e[0m"
RESET := $(shell tput -Txterm sgr0)
# Shell Functions
INFO := @bash -c 'printf $(YELLOW); echo "===> $$1"; printf $(NC)' SOME_VALUE
SUCCESS := @bash -c 'printf $(GREEN); echo "===> $$1"; printf $(NC)' SOME_VALUE
# check and inspect Logic