-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpush-docker
More file actions
executable file
·89 lines (79 loc) · 3.66 KB
/
Copy pathpush-docker
File metadata and controls
executable file
·89 lines (79 loc) · 3.66 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
#!/usr/bin/env bash
# ==========================================================================
# __ ____ __ ___ ___ _ _ _
# \ \ / / \/ | |_ _|_ __ __ _ __ _ ___ | _ )_ _(_) |__| |___ _ _
# \ V /| |\/| | | || ' \/ _` / _` / -_) | _ \ || | | / _` / -_) '_|
# \_/ |_| |_| |___|_|_|_\__,_\__, \___| |___/\_,_|_|_\__,_\___|_|
# |___/
#
# --- Virtual Machine Image Builder and System Installation Scripts ---
# https://www.nntb.no/~dreibh/vmimage-builder-scripts/
# ==========================================================================
#
# VM Image Builder Scripts
# Copyright (C) 2017-2026 by Thomas Dreibholz
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# Contact: thomas.dreibholz@gmail.com
# Bash options:
set -euo pipefail
source ./directories.config
declare -A multiPlatformArray
# ====== Push containers ====================================================
print-utf8 -s "\e[34m====== Pushing Containers ... " "=" "\e[0m"
containers=$(find "${OUTPUT_DIRECTORY}" -mindepth 1 -maxdepth 1 -type d -name "Docker*")
for container in ${containers} ; do
configurationFile="${container}/configuration.json"
successfullyBuiltFile="${container}/successfully-built.txt"
if [ -e "${configurationFile}" ] && [ -e "${successfullyBuiltFile}" ] ; then
repository="$(jq -r '."post-processors"[0][0].repository' "${configurationFile}")"
tag="$(jq -r '."post-processors"[0][0].tags[0]' "${configurationFile}")"
if [ "${repository}" != "" ] && [ "${tag}" != "" ] ; then
print-utf8 -s "\e[33m------ Pushing ${repository}:${tag} ... " "-" "\e[0m"
successfullyPushedFile="${container}/successfully-pushed.txt"
if [ ! -e "${successfullyPushedFile}" ] ; then
docker push "${repository}:${tag}" && date +"%Y-%m-%d %H:%M:%S" >"${successfullyPushedFile}"
else
echo "Already pushed -> nothing to do."
fi
parentTag="${tag/-*/}"
parent="${repository}:${parentTag}"
if [ "${parentTag}" != "${tag}" ] ; then
if test -v multiPlatformArray["${parent}"] ; then
multiPlatformArray[${parent}]="${multiPlatformArray[${parent}]} ${repository}:${tag}"
else
multiPlatformArray[${parent}]="${repository}:${tag}"
fi
else
echo -e "\e[35m${container} does not have a platform-specific tag?!\e[0m"
fi
fi
else
echo -e "\e[35m${container} is not (yet) built!\e[0m"
fi
done
echo ""
# ====== Join multi-platform tags to parent tag =============================
echo ""
print-utf8 -s "\e[34m====== Merging Multi-Platform Containers to Parent Tag ... " "=" "\e[0m"
parents=$(printf "%s\n" "${!multiPlatformArray[@]}" | sort)
for parent in ${parents} ; do
print-utf8 -s "\e[33m------ Merging ${parent} ... " "-" "\e[0m"
children=$(printf "%s\n" "${multiPlatformArray[${parent}]}" | sort)
echo "Platform-specific tags: ${children}"
# shellcheck disable=SC2086
docker buildx imagetools create --tag \
"${parent}" ${children}
done