-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmakefile
223 lines (196 loc) Β· 5.05 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
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
# docker | podman
dev_tool:=docker
cloud:=
docker_image_mkdocs_material_version:=8.1.3
docker_image_mkdocs_material_tag:=our-hello-tasks-mkdocs-material:$(docker_image_mkdocs_material_version)
project_dirs=./src/services/dotnet/webapi \
./src/services/jvm/kotlin/springboot/webapi \
./src/services/jvm/java/springboot/webapi \
./src/services/nodejs/expressjs/webapi
docs_app_port=8000
docs_host_port:=8000
docs_container_name:=our-hello-docs
.DEFAULT_GOAL:=install
all: install
.PHONY: init
init:
ifneq ("$(dev_tool)",$(filter "$(dev_tool)","docker" "podman"))
$(error The "$@" command target only supports "dev_tool=docker" or "dev_tool=podman")
endif
@set -eu; \
prev_dir=$(shell pwd); \
cd ./src/docker/mkdocs && make install; \
cd $$prev_dir; \
$(dev_tool) tag $(docker_image_mkdocs_material_tag) mkdocs;
.PHONY: install-docs
install-docs: init
ifneq ("$(dev_tool)",$(filter "$(dev_tool)","docker" "podman"))
$(error The "$@" command target only supports "dev_tool=docker" or "dev_tool=podman")
endif
@set -eu \
&& $(dev_tool) run \
--name $(docs_container_name)-$@ \
--rm \
-i \
--volume "$(shell pwd)":/app \
--workdir /app \
mkdocs \
build \
--clean \
--site-dir ./docs \
--config-file ./mkdocs.yml
.PHONY: debug-docs
debug-docs: init
ifneq ("$(dev_tool)",$(filter "$(dev_tool)","docker" "podman"))
$(error The "$@" command target only supports "dev_tool=docker" or "dev_tool=podman")
endif
@set -eu \
&& $(dev_tool) run \
--name $(docs_container_name)-$@ \
--rm \
-i \
--volume "$(shell pwd)":/app \
--workdir /app \
--entrypoint "/bin/ash" \
mkdocs
.PHONY: start-docs
start-docs: init
ifneq ("$(dev_tool)",$(filter "$(dev_tool)","docker" "podman"))
$(error The "$@" command target only supports "dev_tool=docker" or "dev_tool=podman")
endif
@set -eu \
&& $(dev_tool) run \
--name $(docs_container_name) \
--detach \
--volume "$(shell pwd)":/app \
--workdir /app \
--publish $(docs_app_port):$(docs_host_port) \
mkdocs \
serve \
-a 0.0.0.0:$(docs_app_port) \
--livereload \
--watch-theme \
--config-file ./mkdocs.yml
@echo 'Successfully started: http://localhost:$(docs_host_port)'
# NOTE: sleep command ensures the container has successfully started
# Ideally, this would script a container status check and URL ping instead.
.PHONY: check-docs
check-docs:
@set -eu; \
make start-docs; \
sleep 5; \
prev_dir=$(shell pwd); \
cd ./src/puppeteer && make check; \
cd $$prev_dir; \
make stop-docs;
.PHONY: stop-docs
stop-docs:
ifneq ("$(dev_tool)",$(filter "$(dev_tool)","docker" "podman"))
$(error The "$@" command target only supports "dev_tool=docker" or "dev_tool=podman")
endif
@set -eu \
&& $(dev_tool) rm --force our-hello-docs
.PHONY: restart-docs
restart-docs: stop-docs start-docs
.PHONY: view-docs-logs
view-docs-logs:
ifneq ("$(dev_tool)",$(filter "$(dev_tool)","docker" "podman"))
$(error The "$@" command target only supports "dev_tool=docker" or "dev_tool=podman")
endif
@set -eu \
&& $(dev_tool) logs \
--tail 1000 \
--follow \
$(docs_container_name)
.PHONY: own-docs
own-docs:
@set -eu \
&& sudo chown -R $(shell whoami) ./docs
.PHONY: install
install: install-docs
@set -eu; \
for project_dir in $(project_dirs); do \
prev_dir=$(shell pwd); \
cd $$project_dir && make $@; \
cd $$prev_dir; \
done
.PHONY: start
start: start-docs
@set -eu; \
for project_dir in $(project_dirs); do \
prev_dir=$(shell pwd); \
cd $$project_dir && make $@; \
cd $$prev_dir; \
done
.PHONY: stop
stop: stop-docs
@set -eu; \
for project_dir in $(project_dirs); do \
prev_dir=$(shell pwd); \
cd $$project_dir && make $@; \
cd $$prev_dir; \
done
.PHONY: clean
clean:
@set -eu; \
docker rmi -f $(docker images | grep 'our-hello-'); \
for project_dir in $(project_dirs); do \
prev_dir=$(shell pwd); \
cd $$project_dir && make $@; \
cd $$prev_dir; \
done
.PHONY: console
console:
@echo "Open your cloud console at:"
ifeq '$(cloud)' 'aws'
@echo "https://console.aws.amazon.com/"
else ifeq '$(cloud)' 'azure'
@echo "https://portal.azure.com/"
else ifeq '$(cloud)' 'gcloud'
@echo "https://console.cloud.google.com/"
else ifeq '$(cloud)' 'heroku'
@echo "https://dashboard.heroku.com/"
endif
# convenience aliases
build: install
up: start
run: start
serve: start
down: stop
uninstall: clean
portal: console
dashboard: console
.PHONY: init-cli
init-cli:
@yarn; \
prev_dir=$(shell pwd); \
echo ''; \
cd ./src/cli/ourc && yarn; \
cd $$prev_dir;
.PHONY: pr
pr: init-cli
@yarn our git pr
.PHONY: sync
sync: init-cli
@yarn our git sync
.PHONY: main
main: init-cli
@yarn our git main
check_projects=./src/docker/aws-cli \
./src/docker/aws-cli-dotnet-sdk \
./src/docker/azure-cli \
./src/docker/heroku-cli \
./src/docker/mkdocs \
./src/services/dotnet/webapi \
./src/services/jvm/java/springboot/webapi \
./src/services/jvm/kotlin/springboot/webapi \
./src/services/nodejs/expressjs/webapi
.PHONY: check-versions
check-versions:
@./check-versions.sh; \
for project_dir in $(check_projects); do \
prev_dir=$(shell pwd); \
echo ''; \
cd $$project_dir && make $@; \
cd $$prev_dir; \
done