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.

This commit is contained in:
Torsten Schulz (local)
2025-10-20 09:55:26 +02:00
parent 9c31e6be71
commit 8b1a3368e2

View File

@@ -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)