From 8b1a3368e2365f755aec08623ee4e162e2512b0f Mon Sep 17 00:00:00 2001 From: "Torsten Schulz (local)" Date: Mon, 20 Oct 2025 09:55:26 +0200 Subject: [PATCH] Enhance deploy script to improve npm installation process by configuring npm settings for reduced output and faster installations. Implement fallback mechanism for npm ci command to ensure reliability during dependency installation for both backend and frontend. Update mysqldump command to use --no-tablespaces to avoid PROCESS privilege issues during database backups. --- deploy.sh | 52 +++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 47 insertions(+), 5 deletions(-) diff --git a/deploy.sh b/deploy.sh index 14c0893..af26924 100755 --- a/deploy.sh +++ b/deploy.sh @@ -197,7 +197,18 @@ setup_backend() { cd $BACKEND_DIR print_info "Installiere Backend-Dependencies..." - npm install --production + # npm Konfiguration verhärten (weniger Hänger/Output) + npm config set fund false >/dev/null 2>&1 || true + npm config set audit false >/dev/null 2>&1 || true + npm config set progress false >/dev/null 2>&1 || true + npm config set loglevel warn >/dev/null 2>&1 || true + # Schnelle, reproduzierbare Installation nur Prod-Dependencies + timeout 600 bash -lc "npm ci --omit=dev --no-audit --no-fund --silent --loglevel=warn --no-progress" || { + print_warning "npm ci ist fehlgeschlagen oder hat zu lange gedauert. Versuche fallback ohne timeout..." + npm ci --omit=dev --no-audit --no-fund --silent --loglevel=warn --no-progress || { + print_error "npm ci (Backend) fehlgeschlagen"; exit 1; + } + } if [ ! -f .env ]; then print_warning ".env Datei nicht gefunden!" @@ -223,7 +234,17 @@ setup_frontend() { cd $FRONTEND_DIR print_info "Installiere Frontend-Dependencies..." - npm install + # npm Konfiguration verhärten + npm config set fund false >/dev/null 2>&1 || true + npm config set audit false >/dev/null 2>&1 || true + npm config set progress false >/dev/null 2>&1 || true + npm config set loglevel warn >/dev/null 2>&1 || true + timeout 600 bash -lc "npm ci --omit=dev --no-audit --no-fund --silent --loglevel=warn --no-progress" || { + print_warning "npm ci ist fehlgeschlagen oder hat zu lange gedauert. Versuche fallback ohne timeout..." + npm ci --omit=dev --no-audit --no-fund --silent --loglevel=warn --no-progress || { + print_error "npm ci (Frontend) fehlgeschlagen"; exit 1; + } + } # .env.production erstellen falls nicht vorhanden if [ ! -f ".env.production" ]; then @@ -465,7 +486,16 @@ do_update() { # Backend aktualisieren print_info "Aktualisiere Backend Dependencies..." cd $BACKEND_DIR - npm install --production + npm config set fund false >/dev/null 2>&1 || true + npm config set audit false >/dev/null 2>&1 || true + npm config set progress false >/dev/null 2>&1 || true + npm config set loglevel warn >/dev/null 2>&1 || true + timeout 600 bash -lc "npm ci --omit=dev --no-audit --no-fund --silent --loglevel=warn --no-progress" || { + print_warning "npm ci ist fehlgeschlagen oder hat zu lange gedauert. Versuche fallback ohne timeout..." + npm ci --omit=dev --no-audit --no-fund --silent --loglevel=warn --no-progress || { + print_error "npm ci (Backend Update) fehlgeschlagen"; exit 1; + } + } # Frontend aktualisieren print_info "Aktualisiere Frontend..." @@ -480,7 +510,16 @@ VITE_API_URL=/api EOF fi - npm install + npm config set fund false >/dev/null 2>&1 || true + npm config set audit false >/dev/null 2>&1 || true + npm config set progress false >/dev/null 2>&1 || true + npm config set loglevel warn >/dev/null 2>&1 || true + timeout 600 bash -lc "npm ci --omit=dev --no-audit --no-fund --silent --loglevel=warn --no-progress" || { + print_warning "npm ci ist fehlgeschlagen oder hat zu lange gedauert. Versuche fallback ohne timeout..." + npm ci --omit=dev --no-audit --no-fund --silent --loglevel=warn --no-progress || { + print_error "npm ci (Frontend Update) fehlgeschlagen"; exit 1; + } + } # Sauberer Build rm -rf dist/ @@ -519,7 +558,10 @@ do_backup() { DB_USER=$(grep DB_USER $BACKEND_DIR/.env | cut -d '=' -f2) DB_PASSWORD=$(grep DB_PASSWORD $BACKEND_DIR/.env | cut -d '=' -f2) - mysqldump -u $DB_USER -p"$DB_PASSWORD" $DB_NAME | gzip > "$BACKUP_DIR/${PROJECT_NAME,,}_$TIMESTAMP.sql.gz" + # Verwende --no-tablespaces um PROCESS-Privileg zu vermeiden + mysqldump --no-tablespaces -u $DB_USER -p"$DB_PASSWORD" $DB_NAME | gzip > "$BACKUP_DIR/${PROJECT_NAME,,}_$TIMESTAMP.sql.gz" || { + print_warning "mysqldump mit --no-tablespaces fehlgeschlagen. Erzeuge nur Code-Backup." + } print_info "Erstelle Code-Backup..." tar -czf "$BACKUP_DIR/${PROJECT_NAME,,}_code_$TIMESTAMP.tar.gz" -C $(dirname $PROJECT_DIR) $(basename $PROJECT_DIR)