forked from ideal-postcodes/postcodes.io
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
112 lines (92 loc) · 2.57 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
103
104
105
106
107
108
109
110
111
112
.DEFAULT_GOAL := help
## -- Main Methods --
## Launch application and database
.PHONY: init
init:
docker-compose up
## -- Development Methods --
## Launch services to support development environment
.PHONY: up
up:
docker-compose -f docker/dev/docker-compose.yml up -d
## Terminate development environment
.PHONY: down
down:
docker-compose -f docker/dev/docker-compose.yml down
## Tail development service logs
.PHONY: logs
logs:
docker-compose -f docker/dev/docker-compose.yml logs -f
## Open psql shell to development pg instance
.PHONY: psql
psql:
psql -h 0.0.0.0 --username postcodesio postcodesiodb
## -- Test Methods --
## Launches test and pg containers with tests running
.PHONY: test
test:
docker-compose -f docker/test/docker-compose.yml -f docker/test/test.yml up --exit-code-from api --build
## Launch test application and database
.PHONY: test-up
test-up:
docker-compose -f docker/test/docker-compose.yml up -d --build
## Shut down test services
.PHONY: test-down
test-down:
docker-compose -f docker/test/docker-compose.yml down
## Shell into test container
.PHONY: test-shell
test-shell:
docker-compose -f docker/test/docker-compose.yml exec api /bin/bash
## Tail test service logs
.PHONY: test-logs
test-logs:
docker-compose -f docker/test/docker-compose.yml logs -f
## -- Live Test Methods --
## Build local pg and api images using pg_dump from S3
.PHONY: live-up
live-up:
docker-compose -f docker/live-test/docker-compose.yml up -d --build
## Shut down live test services
.PHONY: live-down
live-down:
docker-compose -f docker/live-test/docker-compose.yml down -v
## -- Misc --
## Update repository against origin/master
.PHONY: update
update:
git fetch
git merge --ff-only origin/master
## How to use this Makefile
.PHONY: help
help:
@printf "Usage\n";
@awk '{ \
if ($$0 ~ /^.PHONY: [a-zA-Z\-\_0-9]+$$/) { \
helpCommand = substr($$0, index($$0, ":") + 2); \
if (helpMessage) { \
printf "\033[36m%-20s\033[0m %s\n", \
helpCommand, helpMessage; \
helpMessage = ""; \
} \
} else if ($$0 ~ /^[a-zA-Z\-\_0-9.]+:/) { \
helpCommand = substr($$0, 0, index($$0, ":")); \
if (helpMessage) { \
printf "\033[36m%-20s\033[0m %s\n", \
helpCommand, helpMessage; \
helpMessage = ""; \
} \
} else if ($$0 ~ /^##/) { \
if (helpMessage) { \
helpMessage = helpMessage"\n "substr($$0, 3); \
} else { \
helpMessage = substr($$0, 3); \
} \
} else { \
if (helpMessage) { \
print "\n "helpMessage"\n" \
} \
helpMessage = ""; \
} \
}' \
$(MAKEFILE_LIST)