Initial commit: Aquarium Logbuch React/Vite App
- React 18 + Vite Frontend - Node.js/Express Backend - Vollstaendige Logbuch-Funktionalitaet fuer Aquarien - Deploy-Script fuer aqualog CT 211 (192.168.0.246)
This commit is contained in:
108
deploy-v3.sh
Normal file
108
deploy-v3.sh
Normal file
@@ -0,0 +1,108 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
echo "=== Aquarium Logbuch v3 Deploy ==="
|
||||
|
||||
# 1. Download aquascape header photo (CC0 from Pixabay)
|
||||
echo "[1/7] Header-Foto herunterladen..."
|
||||
mkdir -p /tmp/aquarium-deploy/app/public
|
||||
wget -q --timeout=15 -O /tmp/aquarium-deploy/app/public/aquascape.jpg \
|
||||
"https://cdn.pixabay.com/photo/2023/02/08/06/09/aquarium-7776393_1280.jpg" \
|
||||
2>/dev/null && echo " Foto heruntergeladen." || \
|
||||
wget -q --timeout=15 -O /tmp/aquarium-deploy/app/public/aquascape.jpg \
|
||||
"https://cdn.pixabay.com/photo/2017/07/14/15/48/aquarium-2503350_1280.jpg" \
|
||||
2>/dev/null && echo " Foto (Fallback) heruntergeladen." || \
|
||||
echo " WARN: Foto-Download fehlgeschlagen, CSS-Gradient wird als Fallback genutzt."
|
||||
|
||||
# 2. Build frontend
|
||||
echo "[2/7] Frontend bauen..."
|
||||
cd /tmp/aquarium-deploy/app
|
||||
npm run build >> /tmp/build-v3-full.log 2>&1
|
||||
echo " Build abgeschlossen."
|
||||
|
||||
# 3. Deploy frontend
|
||||
echo "[3/7] Frontend deployen..."
|
||||
cp -r dist/* /var/www/aquarium-logbuch/
|
||||
# Copy photo to webroot too if it exists
|
||||
[ -f public/aquascape.jpg ] && cp public/aquascape.jpg /var/www/aquarium-logbuch/aquascape.jpg
|
||||
echo " Frontend kopiert."
|
||||
|
||||
# 4. Install backend
|
||||
echo "[4/7] Backend installieren..."
|
||||
mkdir -p /var/lib/aquarium-backend
|
||||
cp /tmp/backend/server.js /var/lib/aquarium-backend/server.js
|
||||
cp /tmp/backend/package.json /var/lib/aquarium-backend/package.json
|
||||
cd /var/lib/aquarium-backend
|
||||
npm install --omit=dev >> /tmp/build-v3-full.log 2>&1
|
||||
echo " Backend-Pakete installiert."
|
||||
|
||||
# 5. Setup data directory
|
||||
echo "[5/7] Datenverzeichnis anlegen..."
|
||||
mkdir -p /var/lib/aquarium
|
||||
chown -R www-data:www-data /var/lib/aquarium 2>/dev/null || true
|
||||
|
||||
# 6. Create systemd service
|
||||
echo "[6/7] Systemd-Service anlegen..."
|
||||
cat > /etc/systemd/system/aquarium-api.service << 'EOF'
|
||||
[Unit]
|
||||
Description=Aquarium Logbuch API
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
User=root
|
||||
WorkingDirectory=/var/lib/aquarium-backend
|
||||
ExecStart=/usr/bin/node /var/lib/aquarium-backend/server.js
|
||||
Restart=on-failure
|
||||
RestartSec=5
|
||||
StandardOutput=journal
|
||||
StandardError=journal
|
||||
SyslogIdentifier=aquarium-api
|
||||
Environment=NODE_ENV=production
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
EOF
|
||||
systemctl daemon-reload
|
||||
systemctl enable aquarium-api
|
||||
systemctl restart aquarium-api
|
||||
sleep 2
|
||||
systemctl is-active aquarium-api && echo " API-Service läuft." || echo " WARN: API-Service startet nicht, Logs prüfen."
|
||||
|
||||
# 7. Update nginx config
|
||||
echo "[7/7] Nginx konfigurieren..."
|
||||
cat > /etc/nginx/sites-available/aquarium.conf << 'NGINX'
|
||||
server {
|
||||
listen 80 default_server;
|
||||
server_name _;
|
||||
root /var/www/aquarium-logbuch;
|
||||
index index.html;
|
||||
client_max_body_size 10M;
|
||||
|
||||
# API proxy → Node backend
|
||||
location /api {
|
||||
proxy_pass http://127.0.0.1:3001;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_read_timeout 30s;
|
||||
}
|
||||
|
||||
# SPA routing
|
||||
location / {
|
||||
try_files $uri $uri/ /index.html;
|
||||
}
|
||||
|
||||
# Cache static assets
|
||||
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff2)$ {
|
||||
expires 7d;
|
||||
add_header Cache-Control "public, no-transform";
|
||||
}
|
||||
}
|
||||
NGINX
|
||||
nginx -t && nginx -s reload && echo " Nginx neu geladen."
|
||||
|
||||
echo ""
|
||||
echo "=== Deploy abgeschlossen! ==="
|
||||
echo "App: http://$(hostname -I | awk '{print $1}')/"
|
||||
echo "Admin: aqlab / D4sP4sswortBek0mmtKe1ner!"
|
||||
Reference in New Issue
Block a user