This repository has been archived by the owner on Sep 19, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
204 lines (115 loc) · 3.56 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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
CONFIG ?= docker-compose-local.yml
DOCKER_COMPOSE ?= docker-compose -p$(USER)_api -f$(CONFIG)
BLUEPRINT_FILE ?= apiary.apib
BLUEPRINT_TEMPLATE ?= default
WATCH_FILES ?= $(shell \
find node-pathwar/ ./ \
-not -ipath '*/node_modules/*' \
-not -ipath '*/.git/*' \
-not -ipath '*/vendor/*' \
-not -ipath '*~' \
-not -ipath '*.pyc' \
-not -ipath '*\#' \
-type f \
)
REPOS ?= portal.pathwar.net node-pathwar
all: up
# FILES/DIRECTORIES
$(REPOS):
git clone https://github.com/pathwar/$@
spec.json:
$(DOCKER_COMPOSE) run --no-deps nodesdk /bin/bash -c 'curl http://api:5000/docs/spec.json > /data/spec.json'
# ACTIONS
.PHONY: all build release up shell clean kill stop pull re
re: stop up
pull: $(REPOS)
for repo in $(REPOS); do cd $$repo; git pull; cd -; done
build: api_build blueprint_build
release: gh-pages
up: api_up portal_up
stop:
$(DOCKER_COMPOSE) kill
$(DOCKER_COMPOSE) stop
$(DOCKER_COMPOSE) rm --force
logs kill ps:
$(DOCKER_COMPOSE) $@
shell: api_shell
clean: blueprint_clean api_clean portal_clean
# BLUEPRINT
.PHONY: blueprint_watch blueprint_build blueprint_clean
blueprint_watch:
aglio -i $(BLUEPRINT_FILE) -t $(BLUEPRINT_TEMPLATE) -s
blueprint_build:
aglio -i $(BLUEPRINT_FILE) -t $(BLUEPRINT_TEMPLATE) -o apiary.html
blueprint_clean:
-rm -f apiary.html index.html
# GH-PAGES
.PHONY: gh-pages gh-pages_do gh-pages_teardown
gh-pages: spec.json
$(MAKE) gh-pages_do || $(MAKE) gh-pages_teardown
gh-pages_do:
git branch -D gh-pages || true
git checkout -b gh-pages
$(MAKE) blueprint_build
mv apiary.html index.html
git add index.html
git commit index.html -m "Rebuild assets"
git push -u origin gh-pages -f
$(MAKE) gh-pages_teardown
gh-pages_teardown:
git checkout master
# TRAVIS
.PHONY: travis
travis:
find . -name Dockerfile | xargs cat | grep -vi ^maintainer | bash -n
aglio -i $(BLUEPRINT_FILE) -t $(BLUEPRINT_TEMPLATE) -o apiary.html
# API
.PHONY: api_build api_up api_shell portal_up mongo_up smtp_up flush-db seed-db portal_clean
api_build: portal.pathwar.net node-pathwar
$(DOCKER_COMPOSE) build
flush-db: api_up
$(DOCKER_COMPOSE) run --no-deps api python pathwar_api/run.py flush-db
seed-db:
$(MAKE) seed-db-node
seed-db-watch:
while true; do \
clear; \
$(MAKE) seed-db; \
sleep .5; \
fswatch -1 $(WATCH_FILES); \
done
seed-db-node: flush-db node-pathwar
$(DOCKER_COMPOSE) run --no-deps nodesdk npm run seed
pathwar-cli: node-pathwar
$(DOCKER_COMPOSE) run --no-deps nodesdk /bin/bash -ec 'while read cmd; do ./bin/pathwar $$cmd; done'
pathwar-cli-do: node-pathwar
$(DOCKER_COMPOSE) run --no-deps nodesdk /bin/bash -ec './bin/pathwar $(COMMAND)'
seed-db-python: flush-db
$(DOCKER_COMPOSE) run --no-deps api python pathwar_api/run.py seed-db
node-shell:
$(DOCKER_COMPOSE) run --no-deps nodesdk /bin/bash
api_up:
$(DOCKER_COMPOSE) kill api
$(DOCKER_COMPOSE) rm --force api
$(DOCKER_COMPOSE) up --no-recreate -d api
api_logs:
$(DOCKER_COMPOSE) logs api
api_shell: mongo_up
$(DOCKER_COMPOSE) run --no-deps api /bin/bash
mongo_up:
$(DOCKER_COMPOSE) up --no-recreate -d mongo
mongocli:
$(DOCKER_COMPOSE) run mongo /bin/sh -ec 'mongo $${MONGO_HOST:-$${MONGO_PORT_27017_TCP_ADDR}}/pathwar'
smtp_up:
$(DOCKER_COMPOSE) up --no-recreate -d smtp
portal_up:
$(DOCKER_COMPOSE) kill portal
$(DOCKER_COMPOSE) rm --force portal
$(DOCKER_COMPOSE) up --no-recreate -d portal
portal_clean:
-$(DOCKER_COMPOSE) kill portal
-$(DOCKER_COMPOSE) rm --force portal
-rm -rf portal.pathwar.net/build
api_clean:
-$(DOCKER_COMPOSE) stop api
-$(DOCKER_COMPOSE) rm --force api