-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
73 lines (60 loc) · 1.89 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
makefile_path := $(abspath $(lastword $(MAKEFILE_LIST)))
current_dir := $(notdir $(patsubst %/,%,$(dir $(makefile_path))))
envfile := .env
.PHONY: help build build-container rebuild-container start-container stop-container run logs test_coverage
# help target adapted from:
# https://gist.github.com/prwhite/8168133#gistcomment-2278355
TARGET_MAX_CHAR_NUM=20
## Start the services
start-container:
@echo "Pulling images from Docker Hub"
docker-compose pull
@echo "Building Application Image"
docker-compose build app
@echo "Starting Docker Services"
docker-compose up --detach
./build/post-start.sh
build-container:
@echo "building application image"
docker-compose build app
@echo "build completed. exit=$?"
rebuild-container:
@echo "building application image (--no-cache)"
docker-compose build --no-cache app
@echo "build completed. exit=$?"
test_coverage:
go test -coverprofile data/coverage "$1?" && go tool cover -html=data/coverage
## build the app
build:
go build -i -v -ldflags="-X main.version=$(git describe --always --long --dirty)"
## Start the services locally
run:
go run main.go
## Show help
help:
@echo ''
@echo 'Usage:'
@echo ' make <target>'
@echo ''
@echo 'Targets:'
@awk '/^[a-zA-Z_0-9-]+:/ { \
helpMessage = match(lastLine, /^## (.*)/); \
if (helpMessage) { \
helpCommand = substr($$1, 0, index($$1, ":")-1); \
helpMessage = substr(lastLine, RSTART + 3, RLENGTH); \
printf " %-$(TARGET_MAX_CHAR_NUM)s %s\n", helpCommand, helpMessage; \
} \
} \
{ lastLine = $$0 }' $(MAKEFILE_LIST)
## Show the service logs (services must be running)
logs:
docker-compose logs --follow
## Generate certificate private and public key
## Stop services
stop-container:
docker-compose down
docker volume rm $(current_dir)_{app,server}_node_modules 2>/dev/null || true
## Show env
$(envfile):
@echo "Error: .env file does not exist! See the README for instructions."
@exit 1