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