edit function build_image

This commit is contained in:
2025-09-27 22:54:00 +02:00
parent e76ec1ec52
commit 9f58763c9b

View File

@@ -641,7 +641,7 @@ build_image() {
echo "Latest: $latest" >> "$logfile"
echo "====================================" >> "$logfile"
# Plattformen für Buildx
# Plattformen zusammenstellen
local platforms=""
for arch in $architectures; do
case "$arch" in
@@ -653,28 +653,45 @@ build_image() {
done
platforms=${platforms%,} # letztes Komma entfernen
# Tags für alle Registries
if [[ -z "$platforms" ]]; then
whiptail --msgbox "Keine Architekturen ausgewählt. Build abgebrochen." 10 60
return
fi
# Tags für alle registries zusammenstellen
local tags=()
for reg in $registry; do
local reg_url
reg_url=$(get_registry_url "$reg")
if [[ -z "$reg_url" ]]; then
whiptail --msgbox "Registry '$reg' konnte nicht aufgelöst werden. Build abgebrochen." 10 60
return
fi
tags+=("-t" "$reg_url/$image_name:$version")
if [[ "$latest" == "yes" ]]; then
tags+=("-t" "$reg_url/$image_name:latest")
fi
done
# Build-Befehl
local build_cmd="docker buildx build --platform $platforms ${tags[*]} ./projects/$project"
if [[ "$push" == "yes" ]]; then
build_cmd+=" --push"
else
build_cmd+=" --load"
if [[ ${#tags[@]} -eq 0 ]]; then
whiptail --msgbox "Keine gültigen Registries ausgewählt. Build abgebrochen." 10 60
return
fi
echo "$build_cmd" >> "$logfile"
# Build-Befehl zusammenstellen
local build_cmd
build_cmd=(docker buildx build --platform "$platforms" "${tags[@]}" "./projects/$project")
if [[ "$push" == "yes" ]]; then
build_cmd+=(--push)
else
build_cmd+=(--load)
fi
# Log-Ausgabe
echo "${build_cmd[*]}" >> "$logfile"
# Build starten
if ! eval "$build_cmd" >> "$logfile" 2>&1; then
if ! "${build_cmd[@]}" >> "$logfile" 2>&1; then
echo "==== Build fehlgeschlagen: $(date) ====" >> "$logfile"
whiptail --msgbox "Build fehlgeschlagen! Log-Datei: $logfile" 10 70
return