-
Notifications
You must be signed in to change notification settings - Fork 148
/
build_all_images.sh
executable file
·657 lines (495 loc) · 19.3 KB
/
build_all_images.sh
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
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
#!/bin/bash
source ./_common.sh
function build_base_image {
log_in_to_docker_hub
if [[ $(get_latest_docker_hub_version "base") == $(./release_notes.sh get-version) ]] && [[ "${LIFERAY_DOCKER_DEVELOPER_MODE}" != "true" ]]
then
echo ""
echo "Docker image Base is up to date."
return
fi
echo ""
echo "Building Docker image Base."
echo ""
LIFERAY_DOCKER_IMAGE_PLATFORMS="${LIFERAY_DOCKER_IMAGE_PLATFORMS}" LIFERAY_DOCKER_REPOSITORY="${LIFERAY_DOCKER_REPOSITORY}" time ./build_base_image.sh "${BUILD_ALL_IMAGES_PUSH}" | tee -a "${LIFERAY_DOCKER_LOGS_DIR}"/base.log
if [ "${PIPESTATUS[0]}" -gt 0 ]
then
echo "FAILED: Base" >> "${LIFERAY_DOCKER_LOGS_DIR}/results"
exit 1
else
echo "SUCCESS: Base" >> "${LIFERAY_DOCKER_LOGS_DIR}/results"
fi
}
function build_batch_image {
if [[ $(get_latest_docker_hub_version "batch") == $(./release_notes.sh get-version) ]] && [[ "${LIFERAY_DOCKER_DEVELOPER_MODE}" != "true" ]]
then
echo ""
echo "Docker image Batch is up to date."
return
fi
echo ""
echo "Building Docker image Batch."
echo ""
LIFERAY_DOCKER_IMAGE_PLATFORMS="${LIFERAY_DOCKER_IMAGE_PLATFORMS}" LIFERAY_DOCKER_REPOSITORY="${LIFERAY_DOCKER_REPOSITORY}" time ./build_batch_image.sh "${BUILD_ALL_IMAGES_PUSH}" | tee -a "${LIFERAY_DOCKER_LOGS_DIR}"/batch.log
if [ "${PIPESTATUS[0]}" -gt 0 ]
then
echo "FAILED: Batch" >> "${LIFERAY_DOCKER_LOGS_DIR}/results"
exit 1
else
echo "SUCCESS: Batch" >> "${LIFERAY_DOCKER_LOGS_DIR}/results"
fi
}
function build_bundle_image {
local query=${1}
local version=${2}
local additional_tags=$(get_string $( yq "${query}".additional_tags < bundles.yml))
local bundle_url=$(get_string $(yq "${query}".bundle_url < bundles.yml))
local fix_pack_url=$(get_string $(yq "${query}".fix_pack_url < bundles.yml))
local latest=$(get_string $(yq "${query}".latest < bundles.yml))
local test_hotfix_url=$(get_string $(yq "${query}".test_hotfix_url < bundles.yml))
local test_installed_patch=$(get_string $( yq "${query}".test_installed_patch < bundles.yml))
if [ -z "${bundle_url}" ]
then
bundle_url="releases-cdn.liferay.com/dxp/${version}/"$(curl -fsSL "https://releases-cdn.liferay.com/dxp/${version}/.lfrrelease-tomcat-bundle")
fi
if [ -n "${additional_tags}" ]
then
version="${version},${additional_tags}"
fi
if [ ! -n "${version}" ]
then
local build_id=${bundle_url##*/}
else
local build_id=${version}
fi
echo ""
echo "Building Docker image ${build_id} based on ${bundle_url}."
echo ""
LIFERAY_DOCKER_FIX_PACK_URL=${fix_pack_url} LIFERAY_DOCKER_IMAGE_PLATFORMS="${LIFERAY_DOCKER_IMAGE_PLATFORMS}" LIFERAY_DOCKER_LATEST=${latest} LIFERAY_DOCKER_RELEASE_FILE_URL=${bundle_url} LIFERAY_DOCKER_RELEASE_VERSION=${version} LIFERAY_DOCKER_REPOSITORY="${LIFERAY_DOCKER_REPOSITORY}" LIFERAY_DOCKER_TEST_HOTFIX_URL=${test_hotfix_url} LIFERAY_DOCKER_TEST_INSTALLED_PATCHES=${test_installed_patch} time ./build_bundle_image.sh "${BUILD_ALL_IMAGES_PUSH}" 2>&1 | tee "${LIFERAY_DOCKER_LOGS_DIR}/${build_id}.log"
local build_bundle_image_exit_code=${PIPESTATUS[0]}
if [ "${build_bundle_image_exit_code}" -gt 0 ]
then
echo "FAILED: ${build_id}" >> "${LIFERAY_DOCKER_LOGS_DIR}/results"
if [ "${build_bundle_image_exit_code}" -eq 4 ]
then
echo "Detected a license failure while building image ${build_id}." > "${LIFERAY_DOCKER_LOGS_DIR}/license-failure"
echo "There is an existing license failure."
exit 4
fi
else
echo "SUCCESS: ${build_id}" >> "${LIFERAY_DOCKER_LOGS_DIR}/results"
fi
}
function build_bundle_images {
#
# LIFERAY_DOCKER_IMAGE_FILTER="7.2.10-dxp-1 " ./build_all_images.sh
# LIFERAY_DOCKER_IMAGE_FILTER=7.2.10 ./build_all_images.sh
#
local main_keys=$(yq '' < bundles.yml | grep -v ' .*' | sed 's/://')
local specified_version=${LIFERAY_DOCKER_IMAGE_FILTER}
if [ -z "${LIFERAY_DOCKER_IMAGE_FILTER}" ]
then
specified_version="*"
fi
local search_output=$(yq .\""${specified_version}"\" < bundles.yml)
if [[ "${search_output}" != "null" ]]
then
local latest_7413_version=$(yq '."7.4.13"' bundles.yml | grep '^.*:$' | sed 's/://' | sed 's/.*-u//' | sed 's/7.4.13.nightly//' | sort -nr | head -n1)
local versions=$(echo "${search_output}" | grep '^.*:$' | sed 's/://')
for version in ${versions}
do
local main_key=$(get_main_key "${main_keys}" "${version}")
if [[ "${specified_version}" == "*" ]] && [[ "${main_key}" == "7.4.13" ]] && [[ "7.4.13-u${latest_7413_version}" != "${version}" ]]
then
continue
fi
local query=.\"${main_key}\".\"${version}\"
build_bundle_image "${query}" "${version}"
done
else
local main_key=$(get_main_key "${main_keys}" "${specified_version}")
if [[ "${main_key}" = "null" ]]
then
echo "No bundles were found."
exit 1
else
local query=.\"${main_key}\".\"${specified_version}\"
if [[ "$(yq "${query}" < bundles.yml)" != "null" ]]
then
build_bundle_image "${query}" "${specified_version}"
else
echo "No bundles were found."
exit 1
fi
fi
fi
}
function build_caddy_image {
if [[ $(get_latest_docker_hub_version "caddy") == $(./release_notes.sh get-version) ]] && [[ "${LIFERAY_DOCKER_DEVELOPER_MODE}" != "true" ]]
then
echo ""
echo "Docker image Caddy is up to date."
return
fi
echo ""
echo "Building Docker image Caddy resources."
echo ""
LIFERAY_DOCKER_IMAGE_PLATFORMS="${LIFERAY_DOCKER_IMAGE_PLATFORMS}" LIFERAY_DOCKER_REPOSITORY="${LIFERAY_DOCKER_REPOSITORY}" time ./build_caddy_image.sh "${BUILD_ALL_IMAGES_PUSH}" | tee -a "${LIFERAY_DOCKER_LOGS_DIR}"/caddy.log
if [ "${PIPESTATUS[0]}" -gt 0 ]
then
echo "FAILED: Caddy" >> "${LIFERAY_DOCKER_LOGS_DIR}/results"
exit 1
else
echo "SUCCESS: Caddy" >> "${LIFERAY_DOCKER_LOGS_DIR}/results"
fi
}
function build_dynamic_rendering_image {
if [[ $(get_latest_docker_hub_version "job-runner") == $(./release_notes.sh get-version) ]] && [[ "${LIFERAY_DOCKER_DEVELOPER_MODE}" != "true" ]]
then
echo ""
echo "Docker image Dynamic Rendering is up to date."
return
fi
echo ""
echo "Building Docker image Dynamic Rendering."
echo ""
LIFERAY_DOCKER_IMAGE_PLATFORMS="${LIFERAY_DOCKER_IMAGE_PLATFORMS}" LIFERAY_DOCKER_REPOSITORY="${LIFERAY_DOCKER_REPOSITORY}" time ./build_dynamic_rendering_image.sh "${BUILD_ALL_IMAGES_PUSH}" | tee -a "${LIFERAY_DOCKER_LOGS_DIR}"/dynamic_rendering.log
if [ "${PIPESTATUS[0]}" -gt 0 ]
then
echo "FAILED: Dynamic Rendering" >> "${LIFERAY_DOCKER_LOGS_DIR}/results"
exit 1
else
echo "SUCCESS: Dynamic Rendering" >> "${LIFERAY_DOCKER_LOGS_DIR}/results"
fi
}
function build_jar_runner_image {
if [[ $(get_latest_docker_hub_version "jar-runner") == $(./release_notes.sh get-version) ]] && [[ "${LIFERAY_DOCKER_DEVELOPER_MODE}" != "true" ]]
then
echo ""
echo "Docker image JAR Runner is up to date."
return
fi
echo ""
echo "Building Docker image JAR Runner."
echo ""
LIFERAY_DOCKER_IMAGE_PLATFORMS="${LIFERAY_DOCKER_IMAGE_PLATFORMS}" LIFERAY_DOCKER_REPOSITORY="${LIFERAY_DOCKER_REPOSITORY}" time ./build_jar_runner_image.sh "${BUILD_ALL_IMAGES_PUSH}" | tee -a "${LIFERAY_DOCKER_LOGS_DIR}"/jar_runner.log
if [ "${PIPESTATUS[0]}" -gt 0 ]
then
echo "FAILED: JAR Runner" >> "${LIFERAY_DOCKER_LOGS_DIR}/results"
exit 1
else
echo "SUCCESS: JAR Runner" >> "${LIFERAY_DOCKER_LOGS_DIR}/results"
fi
}
function build_jdk_image {
local jdk_friendly_name="${1}"
local jdk_image_name="${2}"
local jdk_version="${3}"
local latest_available_zulu_amd64_version=$(get_latest_available_zulu_version "${jdk_version}" "amd64")
local latest_available_zulu_arm64_version=$(get_latest_available_zulu_version "${jdk_version}" "arm64")
if [[ $(get_latest_docker_hub_zulu_version "${jdk_image_name}" "${jdk_version}" "amd64") == "${latest_available_zulu_amd64_version}" ]] && [[ $(get_latest_docker_hub_zulu_version "${jdk_image_name}" "${jdk_version}" "arm64") == "${latest_available_zulu_arm64_version}" ]] && [[ "${LIFERAY_DOCKER_DEVELOPER_MODE}" != "true" ]]
then
echo ""
echo "Docker image ${jdk_friendly_name} is up to date."
return
fi
echo ""
echo "Building Docker image ${jdk_friendly_name}."
echo ""
LIFERAY_DOCKER_IMAGE_PLATFORMS="${LIFERAY_DOCKER_IMAGE_PLATFORMS}" LIFERAY_DOCKER_REPOSITORY="${LIFERAY_DOCKER_REPOSITORY}" LIFERAY_DOCKER_ZULU_AMD64_VERSION=${latest_available_zulu_amd64_version} LIFERAY_DOCKER_ZULU_ARM64_VERSION=${latest_available_zulu_arm64_version} time ./build_"$(echo "${jdk_image_name}" | sed -r "s/-/_/g")"_image.sh "${BUILD_ALL_IMAGES_PUSH}" | tee -a "${LIFERAY_DOCKER_LOGS_DIR}"/"${jdk_image_name}".log
if [ "${PIPESTATUS[0]}" -gt 0 ]
then
echo "FAILED: ${jdk_friendly_name}" >> "${LIFERAY_DOCKER_LOGS_DIR}/results"
exit 1
else
echo "SUCCESS: ${jdk_friendly_name}" >> "${LIFERAY_DOCKER_LOGS_DIR}/results"
fi
}
function build_job_runner_image {
if [[ $(get_latest_docker_hub_version "job-runner") == $(./release_notes.sh get-version) ]] && [[ "${LIFERAY_DOCKER_DEVELOPER_MODE}" != "true" ]]
then
echo ""
echo "Docker image Job Runner is up to date."
return
fi
echo ""
echo "Building Docker image Job Runner."
echo ""
LIFERAY_DOCKER_IMAGE_PLATFORMS="${LIFERAY_DOCKER_IMAGE_PLATFORMS}" LIFERAY_DOCKER_REPOSITORY="${LIFERAY_DOCKER_REPOSITORY}" time ./build_job_runner_image.sh "${BUILD_ALL_IMAGES_PUSH}" | tee -a "${LIFERAY_DOCKER_LOGS_DIR}"/job_runner.log
if [ "${PIPESTATUS[0]}" -gt 0 ]
then
echo "FAILED: Job Runner" >> "${LIFERAY_DOCKER_LOGS_DIR}/results"
exit 1
else
echo "SUCCESS: Job Runner" >> "${LIFERAY_DOCKER_LOGS_DIR}/results"
fi
}
function build_node_runner_image {
if [[ $(get_latest_docker_hub_version "node-runner") == $(./release_notes.sh get-version) ]] && [[ "${LIFERAY_DOCKER_DEVELOPER_MODE}" != "true" ]]
then
echo ""
echo "Docker image Node Runner is up to date."
return
fi
echo ""
echo "Building Docker image Node Runner."
echo ""
LIFERAY_DOCKER_IMAGE_PLATFORMS="${LIFERAY_DOCKER_IMAGE_PLATFORMS}" LIFERAY_DOCKER_REPOSITORY="${LIFERAY_DOCKER_REPOSITORY}" time ./build_node_runner_image.sh "${BUILD_ALL_IMAGES_PUSH}" | tee -a "${LIFERAY_DOCKER_LOGS_DIR}"/node_runner.log
if [ "${PIPESTATUS[0]}" -gt 0 ]
then
echo "FAILED: Node Runner" >> "${LIFERAY_DOCKER_LOGS_DIR}/results"
exit 1
else
echo "SUCCESS: Node Runner" >> "${LIFERAY_DOCKER_LOGS_DIR}/results"
fi
}
function build_noop_image {
if [[ $(get_latest_docker_hub_version "noop") == $(./release_notes.sh get-version) ]] && [[ "${LIFERAY_DOCKER_DEVELOPER_MODE}" != "true" ]]
then
echo ""
echo "Docker image NOOP is up to date."
return
fi
echo ""
echo "Building Docker image NOOP."
echo ""
LIFERAY_DOCKER_IMAGE_PLATFORMS="${LIFERAY_DOCKER_IMAGE_PLATFORMS}" LIFERAY_DOCKER_REPOSITORY="${LIFERAY_DOCKER_REPOSITORY}" time ./build_noop_image.sh "${BUILD_ALL_IMAGES_PUSH}" | tee -a "${LIFERAY_DOCKER_LOGS_DIR}"/noop.log
if [ "${PIPESTATUS[0]}" -gt 0 ]
then
echo "FAILED: NOOP" >> "${LIFERAY_DOCKER_LOGS_DIR}/results"
exit 1
else
echo "SUCCESS: NOOP" >> "${LIFERAY_DOCKER_LOGS_DIR}/results"
fi
}
function build_squid_image {
if [[ $(get_latest_docker_hub_version "squid") == $(./release_notes.sh get-version) ]] && [[ "${LIFERAY_DOCKER_DEVELOPER_MODE}" != "true" ]]
then
echo ""
echo "Docker image Squid is up to date."
return
fi
echo ""
echo "Building Docker image Squid resources."
echo ""
LIFERAY_DOCKER_IMAGE_PLATFORMS="${LIFERAY_DOCKER_IMAGE_PLATFORMS}" LIFERAY_DOCKER_REPOSITORY="${LIFERAY_DOCKER_REPOSITORY}" time ./build_squid_image.sh "${BUILD_ALL_IMAGES_PUSH}" | tee -a "${LIFERAY_DOCKER_LOGS_DIR}"/squid.log
if [ "${PIPESTATUS[0]}" -gt 0 ]
then
echo "FAILED: Squid" >> "${LIFERAY_DOCKER_LOGS_DIR}/results"
exit 1
else
echo "SUCCESS: Squid" >> "${LIFERAY_DOCKER_LOGS_DIR}/results"
fi
}
function build_zabbix_server_image {
local latest_liferay_zabbix_server_version=$(get_latest_docker_hub_zabbix_server_version "liferay/zabbix-server")
local latest_official_zabbix_server_version=$(get_latest_docker_hub_zabbix_server_version "zabbix/zabbix-server-mysql")
if [[ "${latest_liferay_zabbix_server_version}" == "${latest_official_zabbix_server_version}" ]] && [[ "${LIFERAY_DOCKER_DEVELOPER_MODE}" != "true" ]]
then
echo ""
echo "Docker image Zabbix Server is up to date."
return
fi
echo ""
echo "Building Docker image Zabbix Server."
echo ""
LIFERAY_DOCKER_IMAGE_PLATFORMS="${LIFERAY_DOCKER_IMAGE_PLATFORMS}" LIFERAY_DOCKER_REPOSITORY="${LIFERAY_DOCKER_REPOSITORY}" LIFERAY_DOCKER_ZABBIX_VERSION=${latest_official_zabbix_server_version} time ./build_zabbix_server_image.sh "${BUILD_ALL_IMAGES_PUSH}" | tee -a "${LIFERAY_DOCKER_LOGS_DIR}"/zabbix_server.log
if [ "${PIPESTATUS[0]}" -gt 0 ]
then
echo "FAILED: Zabbix Server" >> "${LIFERAY_DOCKER_LOGS_DIR}/results"
exit 1
else
echo "SUCCESS: Zabbix Server" >> "${LIFERAY_DOCKER_LOGS_DIR}/results"
fi
}
function build_zabbix_web_image {
local latest_liferay_zabbix_server_web_interface_version=$(get_latest_docker_hub_zabbix_server_version "liferay/zabbix-web")
local latest_official_zabbix_server_web_interface_version=$(get_latest_docker_hub_zabbix_server_version "zabbix/zabbix-web-nginx-mysql")
if [[ "${latest_liferay_zabbix_server_web_interface_version}" == "${latest_official_zabbix_server_web_interface_version}" ]] && [[ "${LIFERAY_DOCKER_DEVELOPER_MODE}" != "true" ]]
then
echo ""
echo "Docker image Zabbix Web is up to date."
return
fi
echo ""
echo "Building Docker image Zabbix Web."
echo ""
LIFERAY_DOCKER_IMAGE_PLATFORMS="${LIFERAY_DOCKER_IMAGE_PLATFORMS}" LIFERAY_DOCKER_REPOSITORY="${LIFERAY_DOCKER_REPOSITORY}" LIFERAY_DOCKER_ZABBIX_VERSION=${latest_official_zabbix_server_web_interface_version} time ./build_zabbix_web_image.sh "${BUILD_ALL_IMAGES_PUSH}" | tee -a "${LIFERAY_DOCKER_LOGS_DIR}"/zabbix_server_web_interface.log
if [ "${PIPESTATUS[0]}" -gt 0 ]
then
echo "FAILED: Zabbix Web" >> "${LIFERAY_DOCKER_LOGS_DIR}/results"
exit 1
else
echo "SUCCESS: Zabbix Web" >> "${LIFERAY_DOCKER_LOGS_DIR}/results"
fi
}
function get_latest_available_zulu_version {
local java_version="${1}"
if [ "${java_version}" == "21" ]
then
java_version="21.0.1"
fi
local version=$(\
curl \
--header 'accept: */*' \
--location \
--silent \
"https://api.azul.com/zulu/download/community/v1.0/bundles/latest/?arch=${2}&bundle_type=jdk&ext=deb&hw_bitness=64&javafx=false&java_version=${java_version}&os=linux" | \
jq -r '.zulu_version | join(".")' | \
cut -d '.' -f 1,2,3)
echo "${version}"
}
function get_latest_docker_hub_version {
local token=$(curl -s "https://auth.docker.io/token?scope=repository:liferay/${1}:pull&service=registry.docker.io" | jq -r '.token')
local version=$(curl -s -H "Authorization: Bearer $token" "https://registry-1.docker.io/v2/liferay/${1}/manifests/latest" | grep -o '\\"org.label-schema.version\\":\\"[0-9]\.[0-9]\.[0-9]*\\"' | head -1 | sed 's/\\"//g' | sed 's:.*\:::')
version=$(get_tag_from_image "${version}" "liferay/${1}" "org.label-schema.version:[0-9]*.[0-9]*.[0-9]*")
echo "${version}"
}
function get_latest_docker_hub_zabbix_server_version {
local image_tag="${1}"
local token=$(curl -s "https://auth.docker.io/token?scope=repository:${image_tag}:pull&service=registry.docker.io" | jq -r '.token')
local label_name="org.opencontainers.image.version"
local tag="ubuntu-latest"
if [[ "${image_tag}" =~ "liferay/" ]]
then
label_name="org.label-schema.zabbix-version"
tag="latest"
fi
local version=$(curl -s -H "Authorization: Bearer $token" "https://registry-1.docker.io/v2/${image_tag}/manifests/${tag}" | grep -o "\\\\\"${label_name}\\\\\":\\\\\"[0-9]*\.[0-9]*\.[0-9]*\\\\\"" | head -1 | sed 's/\\"//g' | sed 's:.*\:::')
version=$(get_tag_from_image "${version}" "${image_tag}" "${label_name}:[0-9]*.[0-9]*.[0-9]*")
echo "${version}"
}
function get_latest_docker_hub_zulu_version {
local token=$(curl -s "https://auth.docker.io/token?scope=repository:liferay/${1}:pull&service=registry.docker.io" | jq -r '.token')
local version=$(curl -s -H "Authorization: Bearer $token" "https://registry-1.docker.io/v2/liferay/${1}/manifests/latest" | grep -o "\\\\\"org.label-schema.zulu${2}_${3}_version\\\\\":\\\\\"[0-9]*\.[0-9]*\.[0-9]*\\\\\"" | head -1 | sed 's/\\"//g' | sed 's:.*\:::')
version=$(get_tag_from_image "${version}" "liferay/${1}" "org.label-schema.zulu${2}_${3}_version:[0-9]*.[0-9]*.[0-9]*")
echo "${version}"
}
function get_main_key {
local main_keys=${1}
local version=${2}
if (echo "${version}" | grep -q "q")
then
echo quarterly
return
fi
for main_key in ${main_keys}
do
local count=$(echo "${version}" | grep -c -E "${main_key}-|${main_key}\.")
if [ "${count}" -gt 0 ]
then
echo "${main_key}"
break
fi
done
}
function get_string {
if [ "${1}" == "null" ]
then
echo ""
else
echo "${1}"
fi
}
function get_tag_from_image {
local image_name="${2}"
local filter="${3}"
local version="${1}"
if [ -z "${version}" ]
then
docker pull "${image_name}:latest" >/dev/null
if [ $? -gt 0 ]
then
version="0"
else
version=$(docker image inspect --format '{{index .Config.Labels }}' "${image_name}:latest" | grep -o "${filter}" | sed s/.*://g)
fi
echo "${version}"
else
echo "${version}"
fi
}
function main {
if [[ " ${@} " =~ " --test " ]]
then
return
fi
check_utils 7z curl docker git java jq sed sort tr unzip yq
if [[ " ${@} " =~ " --push " ]]
then
BUILD_ALL_IMAGES_PUSH="push"
./release_notes.sh commit
git push
fi
if [ "${BUILD_ALL_IMAGES_PUSH}" == "push" ] && [ -z "${LIFERAY_DOCKER_IMAGE_PLATFORMS}" ]
then
LIFERAY_DOCKER_IMAGE_PLATFORMS=linux/amd64,linux/arm64
fi
validate_bundles_yml
LIFERAY_DOCKER_LOGS_DIR=logs-$(date "$(date)" "+%Y%m%d%H%M")
export LIFERAY_DOCKER_LOGS_DIR="${LIFERAY_DOCKER_LOGS_DIR}"
mkdir -p "${LIFERAY_DOCKER_LOGS_DIR}"
build_base_image
build_jdk_image "JDK 11" "jdk11" "11"
build_jdk_image "JDK 11 JDK 8" "jdk11-jdk8" "8"
build_jdk_image "JDK 21 JDK 11 JDK 8" "jdk21-jdk11-jdk8" "21"
build_jdk_image "JDK 21" "jdk21" "21"
build_batch_image
build_caddy_image
build_jar_runner_image
build_job_runner_image
build_node_runner_image
build_noop_image
build_squid_image
#build_zabbix_server_image
#build_zabbix_web_image
build_bundle_images
echo ""
echo "Results: "
echo ""
cat "${LIFERAY_DOCKER_LOGS_DIR}/results"
if [ $(grep -c "FAILED" "${LIFERAY_DOCKER_LOGS_DIR}/results") != 0 ]
then
exit 1
fi
}
function validate_bundles_yml {
if [ $(yq '.*.*.latest' < bundles.yml | grep "true" -c) -gt 2 ]
then
echo "There are too many images designated as latest."
exit 1
fi
local dxp_latest_key_counter=0
local main_keys=$(yq '' < bundles.yml | grep -v ' .*' | sed 's/://')
local portal_latest_key_counter=0
for main_key in ${main_keys}
do
if [ $(yq .\""${main_key}"\".*.latest < bundles.yml | grep "true\|false" -c) -gt 0 ]
then
local minor_keys=$(yq .\""${main_key}"\" < bundles.yml | grep -v ' .*' | sed 's/://')
for minor_key in ${minor_keys}
do
if [ $(yq .\""${main_key}"\".\""${minor_key}"\".latest < bundles.yml | grep "true\|false" -c) -gt 0 ]
then
if [ $(yq .\""${main_key}"\".\""${minor_key}"\".bundle_url < bundles.yml | grep "portal-tomcat") ]
then
portal_latest_key_counter=$((portal_latest_key_counter+1))
elif [ $(yq .\""${main_key}"\".\""${minor_key}"\".bundle_url < bundles.yml | grep "dxp-tomcat") ]
then
dxp_latest_key_counter=$((dxp_latest_key_counter+1))
fi
fi
done
fi
done
if [ ${dxp_latest_key_counter} -gt 1 ]
then
echo "There are ${dxp_latest_key_counter} latest DXP images."
exit 1
elif [ ${portal_latest_key_counter} -gt 1 ]
then
echo "There are ${portal_latest_key_counter} latest portal images."
exit 1
fi
}
main "${@}"