Files
stechuhr3/DEPLOYMENT_CHECKLIST.md

211 lines
4.0 KiB
Markdown

# TimeClock v3 - Deployment Checkliste
Diese Checkliste stellt sicher, dass alle Schritte für ein erfolgreiches Deployment durchgeführt wurden.
## Pre-Deployment (Lokal)
- [ ] **Git Status prüfen**: `git status` - Alle Änderungen committed?
- [ ] **Tests durchführen**: Lokal testen mit `npm run dev`
- [ ] **Dependencies aktuell**: `npm install` in backend/ und frontend/
- [ ] **Frontend-Build testen**: `cd frontend && npm run build`
- [ ] **Keine hardcodierten URLs**: `grep -r "localhost:3010" frontend/src/`
## Git Push
```bash
git add .
git commit -m "Deployment vX.X.X"
git push origin main
```
## Server-Vorbereitung
- [ ] **SSH-Zugang**: `ssh tsschulz@tsschulz.de`
- [ ] **Projekt-Verzeichnis**: `cd /var/www/timeclock`
- [ ] **Git Pull**: `git pull origin main`
## Deployment Durchführen
### Option 1: Automatisches Deployment (Empfohlen)
```bash
cd /var/www/timeclock
./deploy.sh update
```
Das Script führt automatisch aus:
- ✅ Datenbank-Backup
- ✅ Backend Dependencies installieren
- ✅ Frontend .env.production erstellen
- ✅ Frontend neu bauen (mit korrekter API-URL)
- ✅ Backend neu starten
- ✅ Apache neu laden
### Option 2: Manuelles Deployment
```bash
# 1. Backup
./deploy.sh backup
# 2. Backend
cd /var/www/timeclock/backend
npm install --production
pm2 restart timeclock-backend
# 3. Frontend
cd /var/www/timeclock/frontend
# .env.production prüfen/erstellen
cat > .env.production << 'EOF'
VITE_API_URL=/api
EOF
npm install
rm -rf dist/
npm run build
# 4. Apache neu laden
sudo systemctl reload apache2
```
## Post-Deployment Tests
- [ ] **Backend Health-Check**:
```bash
curl https://stechuhr3.tsschulz.de/api/health
# Erwartung: {"status":"ok","message":"TimeClock API v3.0.0",...}
```
- [ ] **Frontend lädt**:
```bash
curl -I https://stechuhr3.tsschulz.de
# Erwartung: HTTP/2 200
```
- [ ] **Keine localhost URLs**:
```bash
grep -r "localhost:3010" /var/www/timeclock/frontend/dist/
# Erwartung: Keine Treffer (oder nur Kommentare)
```
- [ ] **PM2 Status**:
```bash
pm2 status
# Erwartung: timeclock-backend | online
```
- [ ] **Browser-Tests**:
- [ ] https://stechuhr3.tsschulz.de lädt
- [ ] Login funktioniert
- [ ] API-Calls gehen an `/api` (nicht `localhost:3010`)
- [ ] Keine Console-Errors (F12)
## Rollback bei Problemen
```bash
cd /var/www/timeclock
./deploy.sh rollback
```
## Monitoring
```bash
# Backend-Logs live
pm2 logs timeclock-backend
# Apache-Logs
sudo tail -f /var/log/apache2/stechuhr3-error.log
# Backend-Status
./deploy.sh status
# Alle Logs
./deploy.sh logs
```
## Häufige Probleme
### Problem: Frontend zeigt "localhost:3010" Fehler
**Lösung:**
```bash
cd /var/www/timeclock/frontend
cat .env.production # Sollte VITE_API_URL=/api enthalten
rm -rf dist/
npm run build
```
### Problem: API 502 Bad Gateway
**Lösung:**
```bash
pm2 restart timeclock-backend
pm2 logs timeclock-backend --lines 50
```
### Problem: Apache zeigt Default-Page
**Lösung:**
```bash
sudo apache2ctl -S | grep stechuhr3 # Prüfe VirtualHost
sudo systemctl reload apache2
```
### Problem: Browser-Cache
**Lösung:**
- **Strg + Shift + R** (Hard Reload)
- Oder Private/Incognito Window
## Deployment-Frequenz
- **Bugfixes**: Sofort
- **Features**: Nach Testing auf Dev
- **Breaking Changes**: Mit Ankündigung
## Backup-Strategie
- **Automatisch**: Täglich um 2 Uhr (via Cronjob)
- **Manuell**: Vor jedem Deployment
- **Retention**: 30 Tage
- **Location**: `/var/backups/timeclock/`
## Secrets & Credentials
Niemals committen:
- ❌ `.env` Dateien
- ❌ SSL-Zertifikate
- ❌ Datenbank-Passwörter
- ❌ API-Keys
Verwende `.gitignore`:
```
.env
.env.local
.env.production.local
*.key
*.pem
```
## Deployment-Log
Dokumentiere jedes Deployment:
```
Datum: 2025-10-18
Version: v3.0.1
Änderungen:
- API-URLs von hardcoded auf .env umgestellt
- Apache2-Konfiguration korrigiert
- SSL-Zertifikat eingerichtet
Status: ✅ Erfolgreich
Probleme: Keine
```
---
**Viel Erfolg beim Deployment! 🚀**
Bei Fragen: Siehe `DEPLOYMENT.md`, `APACHE2_DEPLOYMENT.md` oder `CHECK_SERVICES.md`