-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtools.makefile
241 lines (178 loc) · 6.25 KB
/
tools.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
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
## Docker project Makefile
# started by Mike Cramer
# on November 15, 2016
#
# Automation for Docker build, test run, and push to registry server.
#
makeBuildTag := ${shell date "+%Y%m%d_%H%M%S"}
#-make_${USER}
## Find all Docker files and get a list of their parent directories.
# These must be stored at the same directory depth.
# I.E. ./distro/app/Dockerfile
searchDepthString = */*
dockerContextFiles = ${wildcard ${searchDepthString}/*Dockerfile}
dockerContextDirs = ${dir ${dockerContextFiles}}
## Actions which will build phony and clean recipes quickly
loggedVerbs = build
# tag push
phonyVerbs = clean run touch build-force
actionVerbs := ${phonyVerbs}
actionVerbs += ${loggedVerbs}
toolPath = Tools/
# tput init
tput_nrml = ${shell tput sgr0}
tput_bold = ${shell tput bold}
tput_undl = ${shell tput smul}
tput_revE = ${shell tput rev}
tput_blnk = ${shell tput blink}
tput_black = ${shell tput setaf 0}
tput_red = ${shell tput setaf 1}
tput_green = ${shell tput setaf 2}
tput_yellow = ${shell tput setaf 3}
tput_blue = ${shell tput setaf 4}
tput_magenta = ${shell tput setaf 5}
tput_cyan = ${shell tput setaf 6}
tput_white = ${shell tput setaf 7}
.SECONDEXPANSION:
#### ---- ---- ---- ---- ---- ---- ----
## Default action when running `make` without an argument
default: cls list usage;
#### ---- ---- ---- ---- ---- ---- ----
## Dependancies are handled by your project's Makefile or GNUmakefile.
# Include this file in your project makefile with the line:
# include tools.makefile
# Then define a list of recipes with dependancies.
# Example:
# distro/app/build: distro/-base/build
#### ---- ---- ---- ---- ---- ---- ----
## Per-Action recipes
## alias
# Build verb sends to bar directory
${foreach anDir,${dockerContextDirs},${anDir}build}: $${dir $$@}
# Bare directory assumes build
${foreach anDir,${dockerContextDirs},${anDir}}: $${dir $$@}build.log
## Logged Verbs
## Build a Dockerfile and log
${foreach anDir,${dockerContextDirs},${anDir}build.log}: $${wildcard $${dir $$@}/*Dockerfile} #$${wildcard $${dir $$@}*}
@echo "${tput_cyan}## $@${tput_nrml}"
@echo "${tput_cyan}# Building the docker image w/ tag ${tput_yellow}${makeBuildTag}${tput_nrml}"
@echo -n " ${tput_green}>${tput_nrml} ${tput_bold}"
${toolPath}dkBuild.sh ${dir $@} ${makeBuildTag} | tee $@
@echo -n "${tput_nrml}"
# ## Tag a Dockerfile and log
# ${foreach anDir,${dockerContextDirs},${anDir}tag.log}:
# @echo "${tput_cyan}## $@${tput_nrml}"
# @echo "${tput_cyan}# Taging the docker image w/ tag ${tput_yellow}${makeBuildTag}${tput_nrml}"
# ${toolPath}dkTag.sh ${dir $@} ${makeBuildTag} | tee $@
# ## Push a Dockerfile and log
# ${foreach anDir,${dockerContextDirs},${anDir}push.log}:
# @echo "${tput_cyan}## $@${tput_nrml}"
# @echo "${tput_cyan}# Pushing the docker image w/ tag ${tput_yellow}${makeBuildTag}${tput_nrml}"
# ${toolPath}dkPush.sh ${dir $@} ${makeBuildTag} | tee $@
## Phony Verbs
# clean
${foreach anDir,${dockerContextDirs},${anDir}clean}: force
-find ${dir $@} -iname "*.log" -delete
## Run a Dockerfile
${foreach anDir,${dockerContextDirs},${anDir}run}: $${dir $$@}build
@echo "${tput_cyan}## $@${tput_nrml}"
@echo "${tput_cyan}# Running the docker image${tput_nrml}"
@echo -n " ${tput_green}>${tput_nrml} ${tput_bold}"
${toolPath}dkRun.sh ${dir $@} /bin/bash
@echo -n "${tput_nrml}"
## Touch a Dockerfile
${foreach anDir,${dockerContextDirs},${anDir}touch}: $${wildcard $${dir $$@}/*Dockerfile}
@echo "${tput_cyan}## $@${tput_nrml}"
@echo "${tput_cyan}# Touching ${dir $@}*Dockerfile${tput_nrml}"
@echo -n " ${tput_green}>${tput_nrml} ${tput_bold}"
touch ${dir $@}*Dockerfile
@echo -n "${tput_nrml}"
## Build-force a Dockerfile
${foreach anDir,${dockerContextDirs},${anDir}build-force}:
${MAKE} ${dir $@}touch
${MAKE} ${dir $@}build
# # Directory followed by one of loggedVerbs
# ${foreach anDir,${dockerContextDirs},${foreach anVerb,${loggedVerbs},${anDir}${anVerb}}}:
#### ---- ---- ---- ---- ---- ---- ----
## The force prerequisite
force: ;
## Phony recipes
.PHONY: default debug list usage cls clean hitman-subtask hitman lsr repo-local force \
build run tag push usage \
${foreach anDir,${dockerContextDirs},${foreach anVerb,${actionVerbs},${anDir}${anVerb}}} \
${foreach anDir,${dockerContextDirs},${anDir}run} \
${foreach anDir,${dockerContextDirs},${anDir}}
#### ---- ---- ----
debug:
@echo "------"
@ENV
@echo "------"
@echo "makeBuildTag: "
@echo " ${makeBuildTag}\n"
@echo "dockerContextFiles: "
@echo " ${dockerContextFiles}\n"
@echo "dockerContextDirs: "
@echo " ${dockerContextDirs}\n"
@echo "------"
#### ---- ---- ----
## List the project's contained Dockerfiles
list:
@echo Dirs found w/ contexts:
@${foreach anDir,${dockerContextDirs},echo " "${anDir};}
@echo
@echo Actions available:
@${foreach anVerb,${actionVerbs},echo " "${anVerb};}
@echo
usage:
@echo "Usage:"
@echo " make <distro>/<application>/<actionVerb>"
@echo
@echo " Sequenced actions defined in the project's Makefile may have other action verbs or be optional."
@echo
@echo "More Help:"
@echo " make <verb>"
@echo
@echo "Example:"
@echo " make centos/-base/build"
@echo
build:
@echo "Usage:"
@echo " make <distro>/<application>/[build[.log]]"
@echo
@echo "'build' depends on the existance of a Dockerfile in the given path"
run:
@echo "Usage:"
@echo " make <distro>/<application>/run[.log]"
@echo
@echo "'run' depends on 'build'"
tag:
@echo "Usage:"
@echo " make <distro>/<application>/tag[.log]"
@echo
@echo "'tag' depends on 'build'"
@echo "'tag' is forced"
push:
@echo "Usage:"
@echo " make <distro>/<application>/push[.log]"
@echo
@echo "'push' depends on 'tag' which is forced"
cls:
clear
## Clean log files
clean: force
-find . -iname "*.log" -delete
#### ---- ---- ---- ---- ---- ---- ----
serverLocalStorageReset_yesIUnderstandWhatThisIsDoing:
rm -r /docker/*
hitman-subtask_DontRunThisByItself:
${toolPath}dkHitman.sh
${toolPath}dkHitman.sh
hitman_yesIUnderstandWhatThisIsDoing: force cls clean hitman-subtask_DontRunThisByItself serverLocalStorageReset_yesIUnderstandWhatThisIsDoing repo-local
lsr: repo-local
repo-local:
docker images
#### ---- ---- ---- ---- ---- ---- ----
server: force;
cd server && ${MAKE}
server_test: force;
cd server && ${MAKE} test