apoGM/deploy.sh
2026-05-20 13:49:04 +02:00

41 lines
1.0 KiB
Bash
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
# deploy.sh App auf Ubuntu-Server deployen
# Ausführen: bash deploy.sh
set -e
APP_DIR="/opt/leihvertraege"
SERVICE="leihvertraege"
echo "→ Abhängigkeiten installieren..."
npm ci
echo "→ App bauen..."
npm run build
echo "→ Dateien nach $APP_DIR kopieren..."
sudo mkdir -p "$APP_DIR"
sudo cp -r build "$APP_DIR/"
sudo cp package.json "$APP_DIR/"
sudo cp package-lock.json "$APP_DIR/"
echo "→ Produktions-Abhängigkeiten installieren..."
cd "$APP_DIR"
sudo npm ci --omit=dev
echo "→ .env prüfen..."
if [ ! -f "$APP_DIR/.env" ]; then
echo " ⚠ Keine .env gefunden bitte anlegen!"
echo " cp .env.example $APP_DIR/.env && nano $APP_DIR/.env"
fi
echo "→ Systemd-Service installieren..."
sudo cp "$OLDPWD/leihvertraege.service" /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable "$SERVICE"
sudo systemctl restart "$SERVICE"
echo "✓ Deployment abgeschlossen."
echo " Status: sudo systemctl status $SERVICE"
echo " Logs: sudo journalctl -u $SERVICE -f"