From 41daccc455f7e60e1bd308f6ebd05e1a795e6882 Mon Sep 17 00:00:00 2001 From: pi-farm Date: Sun, 28 Sep 2025 12:59:22 +0200 Subject: [PATCH] edit function build_image --- scripts/image-builder.sh | 41 +++++++++++++++++++++++++++++----------- 1 file changed, 30 insertions(+), 11 deletions(-) diff --git a/scripts/image-builder.sh b/scripts/image-builder.sh index e04afcd..32f00d8 100755 --- a/scripts/image-builder.sh +++ b/scripts/image-builder.sh @@ -598,17 +598,30 @@ EOF # Projektparameter laden load_project_config() { - local config_file="$1" - registry=$(grep "^registry=" "$config_file" | cut -d= -f2) - image_name=$(grep "^image_name=" "$config_file" | cut -d= -f2) - architectures=$(grep "^architectures=" "$config_file" | cut -d= -f2) - push=$(grep "^push=" "$config_file" | cut -d= -f2) - version=$(grep "^version=" "$config_file" | cut -d= -f2) - latest=$(grep "^latest=" "$config_file" | cut -d= -f2) - git_repo=$(grep "^git_repo=" "$config_file" | cut -d= -f2) - auto_subversion=$(grep "^auto_subversion=" "$config_file" | cut -d= -f2 || echo "no") + local project="$1" + local config_file="$CONFIG_DIR/$project.conf" + if [[ -f "$config_file" ]]; then + echo "Lade Konfiguration für Projekt: $project" + image_name=$(grep "^image_name=" "$config_file" | cut -d= -f2) + dockerfile=$(grep "^dockerfile=" "$config_file" | cut -d= -f2) + context=$(grep "^context=" "$config_file" | cut -d= -f2) + version=$(grep "^version=" "$config_file" | cut -d= -f2) + architectures=$(grep "^architectures=" "$config_file" | cut -d= -f2) + registries=$(grep "^registries=" "$config_file" | cut -d= -f2) + + # Architekturen vereinheitlichen → Kommata in Leerzeichen umwandeln + architectures="${architectures//,/ }" + # Mehrfache Leerzeichen säubern + architectures=$(echo "$architectures" | xargs) + + echo "Geladene Konfiguration: image_name=$image_name, dockerfile=$dockerfile, context=$context, version=$version, architectures=$architectures, registries=$registries" + else + echo "Konfigurationsdatei $config_file nicht gefunden!" + exit 1 + fi } + # Gibt die URL einer Registry anhand des Config-Files zurück get_registry_url() { local reg=$1 @@ -664,17 +677,23 @@ build_image() { echo "====================================" | tee -a "$logfile" # Architekturen-Array vorbereiten + load_project_config "$project" + + local platforms="" + local arch_array=() + # Split nach Leerzeichen read -r -a arch_array <<< "$architectures" - platforms="" + for arch in "${arch_array[@]}"; do case "$arch" in amd64) platforms+="linux/amd64," ;; arm64) platforms+="linux/arm64," ;; armhf) platforms+="linux/arm/v7," ;; x86) platforms+="linux/386," ;; - *) echo "WARNUNG: Unbekannte Architektur '$arch' wird ignoriert." | tee -a "$logfile" ;; + *) echo "WARNUNG: Unbekannte Architektur '$arch' wird ignoriert." ;; esac done + platforms="${platforms%,}" echo "DEBUG platforms='$platforms'" | tee -a "$logfile"