-
-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathdocker-bake.hcl
More file actions
338 lines (301 loc) · 9.51 KB
/
Copy pathdocker-bake.hcl
File metadata and controls
338 lines (301 loc) · 9.51 KB
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
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
// docker-bake.hcl
//
// refinebio image build configuration for `docker buildx bake`.
//
// Usage (local, no Dockerhub creds):
// docker buildx bake base
// docker buildx bake default
// docker buildx bake all
//
// Usage (CI / push):
// DOCKERHUB_REPO=ccdlstaging SYSTEM_VERSION=$CI_TAG PUSH_CACHE=true \
// docker buildx bake all --push
// ---------------------------------------------------------------------------
// Variables - all overridable via environment.
// ---------------------------------------------------------------------------
// Default matches the project's existing tag convention so local builds are
// findable by tag without a registry round-trip.
// TODO: the deploy box runs Ubuntu 18.04 with Buildx v0.10.5, which does not support
// the `description` field in variable blocks (requires Buildx v0.13+). Once the deploy
// box is upgraded to Ubuntu 22.04+, uncomment the description lines below.
variable "DOCKERHUB_REPO" {
// description = "Registry namespace used for image tags (e.g. <repo>/dr_base:<version>)."
default = "ccdlstaging"
}
variable "SYSTEM_VERSION" {
// description = "Tag suffix applied to every built image and cache ref."
default = "local"
}
// Default is the public read-only cache that CI pushes to.
// Note: when DOCKERHUB_REPO differs, cache is also read from DOCKERHUB_REPO
// so writers benefit from their own previously-pushed cache.
variable "CACHE_FROM_REPO" {
// description = "Registry to read cache layers from."
default = "ccdlstaging"
}
// Default false so unauthed local builds don't fail trying to push cache.
variable "PUSH_CACHE" {
// description = "If true, write cache layers to DOCKERHUB_REPO. Requires push access."
default = false
}
// Default amd64 because the Salmon / SRA Toolkit binaries (Dockerfile.salmon,
// Dockerfile.transcriptome) are x86_64-only and some apt packages have no
// arm64 variant.
variable "PLATFORMS" {
// description = "Comma-separated platforms to build for."
default = "linux/amd64"
}
// ---------------------------------------------------------------------------
// Helper functions.
// ---------------------------------------------------------------------------
function "tags_for" {
params = [name]
result = [
"${DOCKERHUB_REPO}/dr_${name}:${SYSTEM_VERSION}",
"${DOCKERHUB_REPO}/dr_${name}:latest",
]
}
function "cache_from_for" {
params = [name]
result = concat(
[
"type=registry,ref=${CACHE_FROM_REPO}/dr_${name}_cache:latest",
"type=registry,ref=${CACHE_FROM_REPO}/dr_${name}_cache:${SYSTEM_VERSION}",
],
DOCKERHUB_REPO != CACHE_FROM_REPO ? [
"type=registry,ref=${DOCKERHUB_REPO}/dr_${name}_cache:latest",
"type=registry,ref=${DOCKERHUB_REPO}/dr_${name}_cache:${SYSTEM_VERSION}",
] : []
)
}
function "cache_to_for" {
params = [name]
result = PUSH_CACHE ? [
"type=registry,ref=${DOCKERHUB_REPO}/dr_${name}_cache:latest,mode=max",
"type=registry,ref=${DOCKERHUB_REPO}/dr_${name}_cache:${SYSTEM_VERSION},mode=max",
] : []
}
// Wire a child target's `FROM` line to a sibling parent target.
// Eliminates the registry round-trip that
// FROM ${DOCKERHUB_REPO}/dr_<parent>:${SYSTEM_VERSION}
// would otherwise need.
function "from_target" {
params = [parent]
result = {
"${DOCKERHUB_REPO}/dr_${parent}:${SYSTEM_VERSION}" = "target:${parent}"
}
}
// ---------------------------------------------------------------------------
// Abstract base target - concrete targets inherit platform + build args.
// ---------------------------------------------------------------------------
target "_common" {
context = "."
platforms = split(",", PLATFORMS)
args = {
DOCKERHUB_REPO = DOCKERHUB_REPO
SYSTEM_VERSION = SYSTEM_VERSION
}
}
// ---------------------------------------------------------------------------
// common/ images.
// ---------------------------------------------------------------------------
target "base" {
inherits = ["_common"]
dockerfile = "common/dockerfiles/Dockerfile.base"
tags = tags_for("base")
cache-from = cache_from_for("base")
cache-to = cache_to_for("base")
}
target "migrations" {
inherits = ["_common"]
dockerfile = "common/dockerfiles/Dockerfile.migrations"
contexts = from_target("base")
tags = tags_for("migrations")
cache-from = cache_from_for("migrations")
cache-to = cache_to_for("migrations")
}
target "common_tests" {
inherits = ["_common"]
dockerfile = "common/dockerfiles/Dockerfile.common_tests"
contexts = from_target("base")
tags = tags_for("common_tests")
cache-from = cache_from_for("common_tests")
cache-to = cache_to_for("common_tests")
}
// ---------------------------------------------------------------------------
// api/ images.
// ---------------------------------------------------------------------------
target "api_base" {
inherits = ["_common"]
dockerfile = "api/dockerfiles/Dockerfile.api_base"
tags = tags_for("api_base")
cache-from = cache_from_for("api_base")
cache-to = cache_to_for("api_base")
}
target "api" {
inherits = ["_common"]
dockerfile = "api/dockerfiles/Dockerfile.api"
contexts = from_target("api_base")
tags = tags_for("api")
cache-from = cache_from_for("api")
cache-to = cache_to_for("api")
}
target "api_local" {
inherits = ["_common"]
dockerfile = "api/dockerfiles/Dockerfile.api_local"
contexts = from_target("api_base")
tags = tags_for("api_local")
cache-from = cache_from_for("api_local")
cache-to = cache_to_for("api_local")
}
// ---------------------------------------------------------------------------
// foreman/.
// ---------------------------------------------------------------------------
target "foreman" {
inherits = ["_common"]
dockerfile = "foreman/dockerfiles/Dockerfile.foreman"
contexts = from_target("base")
tags = tags_for("foreman")
cache-from = cache_from_for("foreman")
cache-to = cache_to_for("foreman")
}
// ---------------------------------------------------------------------------
// workers/ images.
// ---------------------------------------------------------------------------
target "transcriptome" {
inherits = ["_common"]
dockerfile = "workers/dockerfiles/Dockerfile.transcriptome"
contexts = from_target("base")
tags = tags_for("transcriptome")
cache-from = cache_from_for("transcriptome")
cache-to = cache_to_for("transcriptome")
}
target "smasher" {
inherits = ["_common"]
dockerfile = "workers/dockerfiles/Dockerfile.smasher"
contexts = from_target("base")
tags = tags_for("smasher")
cache-from = cache_from_for("smasher")
cache-to = cache_to_for("smasher")
}
target "salmon" {
inherits = ["_common"]
dockerfile = "workers/dockerfiles/Dockerfile.salmon"
contexts = from_target("base")
tags = tags_for("salmon")
cache-from = cache_from_for("salmon")
cache-to = cache_to_for("salmon")
}
target "no_op" {
inherits = ["_common"]
dockerfile = "workers/dockerfiles/Dockerfile.no_op"
contexts = from_target("base")
tags = tags_for("no_op")
cache-from = cache_from_for("no_op")
cache-to = cache_to_for("no_op")
}
target "illumina" {
inherits = ["_common"]
dockerfile = "workers/dockerfiles/Dockerfile.illumina"
contexts = from_target("base")
tags = tags_for("illumina")
cache-from = cache_from_for("illumina")
cache-to = cache_to_for("illumina")
}
target "downloaders" {
inherits = ["_common"]
dockerfile = "workers/dockerfiles/Dockerfile.downloaders"
contexts = from_target("base")
tags = tags_for("downloaders")
cache-from = cache_from_for("downloaders")
cache-to = cache_to_for("downloaders")
}
target "compendia" {
inherits = ["_common"]
dockerfile = "workers/dockerfiles/Dockerfile.compendia"
contexts = from_target("base")
tags = tags_for("compendia")
cache-from = cache_from_for("compendia")
cache-to = cache_to_for("compendia")
}
// Affymetrix is opt-in (heavy build, ~75 GB disk required).
target "affymetrix" {
inherits = ["_common"]
dockerfile = "workers/dockerfiles/Dockerfile.affymetrix"
contexts = from_target("base")
tags = tags_for("affymetrix")
cache-from = cache_from_for("affymetrix")
cache-to = cache_to_for("affymetrix")
}
// ---------------------------------------------------------------------------
// Groups.
// ---------------------------------------------------------------------------
group "workers" {
targets = [
"transcriptome",
"smasher",
"salmon",
"no_op",
"illumina",
"downloaders",
"compendia",
]
}
// `default` is every image except affymetrix (which is opt-in via the
// `affymetrix` target or the `all` group).
group "default" {
targets = [
"base",
"migrations",
"common_tests",
"foreman",
"api_base",
"api",
"api_local",
"transcriptome",
"smasher",
"salmon",
"no_op",
"illumina",
"downloaders",
"compendia",
]
}
// `all` includes affymetrix.
group "all" {
targets = [
"base",
"migrations",
"common_tests",
"foreman",
"api_base",
"api",
"api_local",
"transcriptome",
"smasher",
"salmon",
"no_op",
"illumina",
"downloaders",
"compendia",
"affymetrix",
]
}
// `deploy` is the set CI builds and pushes during a tagged deploy.
// Excludes test-only images (migrations, common_tests, api_local).
group "deploy" {
targets = [
"base",
"api_base",
"api",
"foreman",
"smasher",
"compendia",
"illumina",
"affymetrix",
"salmon",
"transcriptome",
"no_op",
"downloaders",
]
}