diff --git a/scripts/image-builder.sh b/scripts/image-builder.sh index aaa53e6..4506075 100755 --- a/scripts/image-builder.sh +++ b/scripts/image-builder.sh @@ -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 @@ -651,30 +651,47 @@ build_image() { x86) platforms+="linux/386," ;; esac 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=() 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