-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Expand file tree
/
Copy pathdocker-bake.hcl
More file actions
379 lines (328 loc) · 11.1 KB
/
docker-bake.hcl
File metadata and controls
379 lines (328 loc) · 11.1 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
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
// =========================
// docker-bake.hcl (3-phase)
// =========================
// ----- Variables -----
variable "OS" {
type = string
default = "alpine"
description = "Base Operating System for building images. Allowed: alpine|centos|ol|ubuntu"
}
variable "ZBX_VERSION" {
type = string
default = "7.4"
description = "Zabbix branch or exact version to build"
}
variable "OS_BASE_IMAGE" {
type = string
default = "alpine:3.23"
description = "Base image for images. Passed to Dockerfiles as OS_BASE_IMAGE"
}
variable "ZBX_IMAGE_TAG" {
type = string
default = "${OS}-${ZBX_VERSION}-local"
description = "Image tag for all images. For example, \"alpine-7.4-local\""
}
variable "PLATFORMS" {
type = string
default = ""
description = "Target platform list. For example, \"linux/amd64,linux/arm64\""
}
variable "ZBX_IMAGE_NAMESPACE" {
type = string
default = ""
description = "Zabbix registry and namespace. For example \"zabbix/\""
}
variable "ZBX_IMAGE_PREFIX" {
type = string
default = "zabbix-"
description = "Prefix for Zabbix images"
}
// ----- Groups (3-phase) -----
group "base" {
targets = ["build-base"]
}
group "builder-mysql" {
targets = ["build-mysql"]
}
group "builder-pgsql" {
targets = ["build-pgsql"]
}
group "builder-sqlite3" {
targets = ["build-sqlite3"]
}
group "runtime-mysql-all" {
targets = [
// common
"agent-mysql",
"agent2-mysql",
"java-gateway-mysql",
"web-service-mysql",
"server-mysql",
"web-nginx-mysql",
"web-apache-mysql",
// db-specific fixed components
"proxy-mysql",
// No dependencies from build images
"snmptraps"
]
}
group "runtime-pgsql-all" {
targets = [
// common
"agent-pgsql",
"agent2-pgsql",
"java-gateway-pgsql",
"web-service-pgsql",
"server-pgsql",
"web-nginx-pgsql",
"web-apache-pgsql",
// No dependencies from build images
"snmptraps"
]
}
group "runtime-mysql-minimal" {
targets = [
// common
"agent-mysql",
"server-mysql",
"web-nginx-mysql"
]
}
group "runtime-pgsql-minimal" {
targets = [
// common
"agent-pgsql",
"server-pgsql",
"web-nginx-pgsql"
]
}
group "runtime-mysql-apache" {
targets = [
// common
"agent-mysql",
"server-mysql",
"web-apache-mysql"
]
}
group "runtime-pgsql-apache" {
targets = [
// common
"agent-pgsql",
"server-pgsql",
"web-apache-pgsql"
]
}
group "runtime-sqlite3" {
targets = [
// common
"agent-mysql",
"proxy-sqlite3"
]
}
// Keep default minimal to avoid surprises
group "default" { targets = ["base"] }
// ----- Common templates -----
target "_common" {
args = {
OS_BASE_IMAGE = OS_BASE_IMAGE
BUILDKIT_INLINE_CACHE = "1"
}
platforms = notequal(PLATFORMS, "") ? split(",", replace(PLATFORMS, " ", "")) : null
}
target "_builder_common" {
inherits = ["_common"]
contexts = {
config_templates = "config_templates",
sources = "sources"
}
dockerfile = "Dockerfile"
args = {
BUILD_BASE_IMAGE = "${ZBX_IMAGE_NAMESPACE}zabbix-build-base:${ZBX_IMAGE_TAG}"
}
}
// For runtime images that depend on DB-flavored builder env
target "_runtime_db_common_mysql" {
inherits = ["_common"]
contexts = {
builder = "target:build-mysql"
}
}
target "_runtime_db_common_pgsql" {
inherits = ["_common"]
contexts = {
builder = "target:build-pgsql"
}
}
// For runtime images that do not depend on DB builder
target "_runtime_nodb" {
inherits = ["_common"]
}
// =========================
// Phase 1: build-base
// =========================
target "build-base" {
description = "Zabbix build base image contains all required packages to build Zabbix images"
inherits = ["_common"]
context = "Dockerfiles/build-base/${OS}"
tags = ["${ZBX_IMAGE_NAMESPACE}${ZBX_IMAGE_PREFIX}build-base:${ZBX_IMAGE_TAG}"]
}
// =========================
// Phase 2: builders per DB
// =========================
target "build-mysql" {
description = "Zabbix build base for MySQL based images"
inherits = ["_builder_common"]
context = "Dockerfiles/build-mysql/${OS}"
tags = ["${ZBX_IMAGE_NAMESPACE}${ZBX_IMAGE_PREFIX}build-mysql:${ZBX_IMAGE_TAG}"]
}
target "build-pgsql" {
description = "Zabbix build base for PostgreSQL based images"
inherits = ["_builder_common"]
depends_on = ["build-base"]
context = "Dockerfiles/build-pgsql/${OS}"
tags = ["${ZBX_IMAGE_NAMESPACE}${ZBX_IMAGE_PREFIX}build-pgsql:${ZBX_IMAGE_TAG}"]
}
target "build-sqlite3" {
description = "Zabbix build base for SQLite3 based images"
inherits = ["_builder_common"]
depends_on = ["build-base"]
context = "Dockerfiles/build-sqlite3/${OS}"
tags = ["${ZBX_IMAGE_NAMESPACE}${ZBX_IMAGE_PREFIX}build-sqlite3:${ZBX_IMAGE_TAG}"]
}
// =========================
// Phase 3: runtime (DB-flavored)
// =========================
// "Common" runtime
target "agent-mysql" {
description = "Zabbix agent is deployed on a monitoring target to actively monitor local resources and applications"
inherits = ["_runtime_db_common_mysql"]
depends_on = ["build-mysql"]
context = "Dockerfiles/agent/${OS}"
tags = ["${ZBX_IMAGE_NAMESPACE}${ZBX_IMAGE_PREFIX}agent:${ZBX_IMAGE_TAG}"]
}
target "agent2-mysql" {
description = "Zabbix agent 2 is deployed on a monitoring target to actively monitor local resources and applications"
inherits = ["_runtime_db_common_mysql"]
depends_on = ["build-mysql"]
context = "Dockerfiles/agent2/${OS}"
tags = ["${ZBX_IMAGE_NAMESPACE}${ZBX_IMAGE_PREFIX}agent2:${ZBX_IMAGE_TAG}"]
}
target "java-gateway-mysql" {
description = "Zabbix Java Gateway performs native support for monitoring JMX applications"
inherits = ["_runtime_db_common_mysql"]
depends_on = ["build-mysql"]
context = "Dockerfiles/java-gateway/${OS}"
tags = ["${ZBX_IMAGE_NAMESPACE}${ZBX_IMAGE_PREFIX}java-gateway:${ZBX_IMAGE_TAG}"]
}
target "web-service-mysql" {
description = "Zabbix web service for performing various tasks using headless web browser"
inherits = ["_runtime_db_common_mysql"]
depends_on = ["build-mysql"]
context = "Dockerfiles/web-service/${OS}"
tags = ["${ZBX_IMAGE_NAMESPACE}${ZBX_IMAGE_PREFIX}web-service:${ZBX_IMAGE_TAG}"]
}
target "agent-pgsql" {
description = "Zabbix agent is deployed on a monitoring target to actively monitor local resources and applications"
inherits = ["_runtime_db_common_pgsql"]
depends_on = ["build-pgsql"]
context = "Dockerfiles/agent/${OS}"
tags = ["${ZBX_IMAGE_NAMESPACE}${ZBX_IMAGE_PREFIX}agent:${ZBX_IMAGE_TAG}"]
}
target "agent2-pgsql" {
description = "Zabbix agent 2 is deployed on a monitoring target to actively monitor local resources and applications"
inherits = ["_runtime_db_common_pgsql"]
depends_on = ["build-pgsql"]
context = "Dockerfiles/agent2/${OS}"
tags = ["${ZBX_IMAGE_NAMESPACE}${ZBX_IMAGE_PREFIX}agent2:${ZBX_IMAGE_TAG}"]
}
target "java-gateway-pgsql" {
description = "Zabbix Java Gateway performs native support for monitoring JMX applications"
inherits = ["_runtime_db_common_pgsql"]
depends_on = ["build-pgsql"]
context = "Dockerfiles/java-gateway/${OS}"
tags = ["${ZBX_IMAGE_NAMESPACE}${ZBX_IMAGE_PREFIX}java-gateway:${ZBX_IMAGE_TAG}"]
}
target "web-service-pgsql" {
description = "Zabbix web service for performing various tasks using headless web browser"
inherits = ["_runtime_db_common_pgsql"]
depends_on = ["build-pgsql"]
context = "Dockerfiles/web-service/${OS}"
tags = ["${ZBX_IMAGE_NAMESPACE}${ZBX_IMAGE_PREFIX}web-service:${ZBX_IMAGE_TAG}"]
}
// Server/Web choose subfolder by DB
target "server-mysql" {
description = "Zabbix server with MySQL database support"
inherits = ["_runtime_db_common_mysql"]
depends_on = ["build-mysql"]
context = "Dockerfiles/server-mysql/${OS}"
tags = ["${ZBX_IMAGE_NAMESPACE}${ZBX_IMAGE_PREFIX}server-mysql:${ZBX_IMAGE_TAG}"]
}
target "web-nginx-mysql" {
description = "Zabbix web-interface based on Nginx web server with MySQL database support"
inherits = ["_runtime_db_common_mysql"]
depends_on = ["build-mysql"]
context = "Dockerfiles/web-nginx-mysql/${OS}"
tags = ["${ZBX_IMAGE_NAMESPACE}${ZBX_IMAGE_PREFIX}web-nginx-mysql:${ZBX_IMAGE_TAG}"]
}
target "web-apache-mysql" {
description = "Zabbix web-interface based on Apache web server with MySQL database support"
inherits = ["_runtime_db_common_mysql"]
depends_on = ["build-mysql"]
context = "Dockerfiles/web-apache-mysql/${OS}"
tags = ["${ZBX_IMAGE_NAMESPACE}${ZBX_IMAGE_PREFIX}web-apache-mysql:${ZBX_IMAGE_TAG}"]
}
target "server-pgsql" {
description = "Zabbix server with PostgreSQL database support"
inherits = ["_runtime_db_common_pgsql"]
depends_on = ["build-pgsql"]
context = "Dockerfiles/server-pgsql/${OS}"
tags = ["${ZBX_IMAGE_NAMESPACE}${ZBX_IMAGE_PREFIX}server-pgsql:${ZBX_IMAGE_TAG}"]
}
target "web-nginx-pgsql" {
description = "Zabbix web-interface based on Nginx web server with PostgreSQL database support"
inherits = ["_runtime_db_common_pgsql"]
depends_on = ["build-pgsql"]
context = "Dockerfiles/web-nginx-pgsql/${OS}"
tags = ["${ZBX_IMAGE_NAMESPACE}${ZBX_IMAGE_PREFIX}web-nginx-pgsql:${ZBX_IMAGE_TAG}"]
}
target "web-apache-pgsql" {
description = "Zabbix web-interface based on Apache web server with PostgreSQL database support"
inherits = ["_runtime_db_common_pgsql"]
depends_on = ["build-pgsql"]
context = "Dockerfiles/web-apache-pgsql/${OS}"
tags = ["${ZBX_IMAGE_NAMESPACE}${ZBX_IMAGE_PREFIX}web-apache-pgsql:${ZBX_IMAGE_TAG}"]
}
// =========================
// Runtime (fixed DB targets)
// =========================
// proxy-mysql: always uses mysql builder (independent of DB variable, depends on build-sqlite3 build image)
target "proxy-mysql" {
description = "Zabbix proxy with MySQL database support"
inherits = ["_common"]
depends_on = ["build-mysql"]
context = "Dockerfiles/proxy-mysql/${OS}"
args = {
BUILD_BASE_IMAGE = "${ZBX_IMAGE_NAMESPACE}${ZBX_IMAGE_PREFIX}build-mysql:${ZBX_IMAGE_TAG}"
}
tags = ["${ZBX_IMAGE_NAMESPACE}${ZBX_IMAGE_PREFIX}proxy-mysql:${ZBX_IMAGE_TAG}"]
}
// proxy-sqlite3: always uses sqlite3 builder (independent of DB variable, depends on build-sqlite3 build image)
target "proxy-sqlite3" {
description = "Zabbix proxy with SQLite3 database support"
inherits = ["_common"]
depends_on = ["build-sqlite3"]
context = "Dockerfiles/proxy-sqlite3/${OS}"
args = {
BUILD_BASE_IMAGE = "${ZBX_IMAGE_NAMESPACE}${ZBX_IMAGE_PREFIX}build-sqlite3:${ZBX_IMAGE_TAG}"
}
tags = ["${ZBX_IMAGE_NAMESPACE}${ZBX_IMAGE_PREFIX}proxy-sqlite3:${ZBX_IMAGE_TAG}"]
}
// =========================
// Runtime (no build images dependency)
// =========================
target "snmptraps" {
description = "Zabbix SNMP traps receiver"
inherits = ["_runtime_nodb"]
context = "Dockerfiles/snmptraps/${OS}"
tags = ["${ZBX_IMAGE_NAMESPACE}${ZBX_IMAGE_PREFIX}snmptraps:${ZBX_IMAGE_TAG}"]
}