- Add pre-flight checks in deploy-update.yml - Automatically copy docker-compose.yml and nginx config in setup-infrastructure.yml - Add comprehensive deployment documentation - Ready for automated code deployments via CI/CD pipeline
247 lines
6.0 KiB
Markdown
247 lines
6.0 KiB
Markdown
# Finale Deployment Checklist - Code deployen
|
|
|
|
**Stand:** 2025-10-31
|
|
**Status:** ✅ Bereit für Code-Deployments!
|
|
|
|
---
|
|
|
|
## ✅ Was ist bereits fertig?
|
|
|
|
### Infrastructure (100%)
|
|
- ✅ Traefik (Reverse Proxy & SSL)
|
|
- ✅ PostgreSQL (Database)
|
|
- ✅ Docker Registry (Private Registry)
|
|
- ✅ Gitea (Git Server)
|
|
- ✅ Monitoring (Portainer, Grafana, Prometheus)
|
|
- ✅ WireGuard VPN
|
|
|
|
### Application Stack (100%)
|
|
- ✅ Integration in `setup-infrastructure.yml`
|
|
- ✅ `.env` Template (`application.env.j2`)
|
|
- ✅ Database-Migration nach Deployment
|
|
- ✅ Health-Checks nach Deployment
|
|
- ✅ `docker-compose.yml` wird automatisch kopiert
|
|
- ✅ Nginx-Konfiguration wird automatisch kopiert
|
|
|
|
### CI/CD Pipeline (100%)
|
|
- ✅ Workflows vorhanden (production-deploy.yml)
|
|
- ✅ Gitea Runner läuft und ist registriert
|
|
- ✅ Secrets konfiguriert (REGISTRY_USER, REGISTRY_PASSWORD, SSH_PRIVATE_KEY)
|
|
- ✅ Ansible Playbooks vorhanden
|
|
- ✅ Deployment-Playbook mit Pre-Flight Checks
|
|
|
|
### Dokumentation (100%)
|
|
- ✅ Umfangreiche Guides vorhanden
|
|
- ✅ Quick Start Guide
|
|
- ✅ Deployment-Dokumentation
|
|
- ✅ Troubleshooting-Guides
|
|
|
|
---
|
|
|
|
## 🚀 Code deployen - So geht's!
|
|
|
|
### Einfachste Methode
|
|
|
|
```bash
|
|
# 1. Code ändern
|
|
# ... Dateien bearbeiten ...
|
|
|
|
# 2. Committen
|
|
git add .
|
|
git commit -m "feat: Add new feature"
|
|
|
|
# 3. Pushen → Automatisches Deployment!
|
|
git push origin main
|
|
```
|
|
|
|
**Pipeline-Status:** `https://git.michaelschiemer.de/michael/michaelschiemer/actions`
|
|
|
|
**Zeit:** ~8-15 Minuten
|
|
|
|
---
|
|
|
|
## ⚠️ Wichtiger Hinweis: Erstmalige Deployment
|
|
|
|
**Falls Application Stack noch nicht deployed ist:**
|
|
|
|
Der `deploy-update.yml` Playbook prüft automatisch, ob `docker-compose.yml` existiert. Falls nicht, gibt es eine klare Fehlermeldung.
|
|
|
|
**Vor dem ersten Code-Push (falls Stack noch nicht deployed):**
|
|
```bash
|
|
cd deployment/ansible
|
|
ansible-playbook -i inventory/production.yml playbooks/setup-infrastructure.yml
|
|
```
|
|
|
|
Dieses Playbook:
|
|
- ✅ Deployed alle Infrastructure Stacks
|
|
- ✅ **Deployed Application Stack** (inkl. docker-compose.yml, .env, nginx config)
|
|
- ✅ Führt Database-Migration aus
|
|
- ✅ Prüft Health-Checks
|
|
|
|
**Nach diesem Setup:** Ab jetzt funktioniert `git push origin main` automatisch!
|
|
|
|
---
|
|
|
|
## 📋 Pre-Deployment Check
|
|
|
|
### Automatische Checks
|
|
|
|
Das `deploy-update.yml` Playbook prüft automatisch:
|
|
- ✅ Docker Service läuft
|
|
- ✅ Application Stack Verzeichnis existiert
|
|
- ✅ `docker-compose.yml` existiert (mit klarer Fehlermeldung falls nicht)
|
|
- ✅ Backup-Verzeichnis kann erstellt werden
|
|
|
|
### Manuelle Checks (Optional)
|
|
|
|
**Application Stack Status prüfen:**
|
|
```bash
|
|
ssh deploy@94.16.110.151
|
|
|
|
# Prüfe docker-compose.yml
|
|
test -f ~/deployment/stacks/application/docker-compose.yml && echo "✅ OK" || echo "❌ Fehlt - Führe setup-infrastructure.yml aus"
|
|
|
|
# Prüfe .env
|
|
test -f ~/deployment/stacks/application/.env && echo "✅ OK" || echo "❌ Fehlt - Führe setup-infrastructure.yml aus"
|
|
|
|
# Prüfe Container
|
|
cd ~/deployment/stacks/application
|
|
docker compose ps
|
|
```
|
|
|
|
**Gitea Runner Status:**
|
|
```bash
|
|
cd deployment/gitea-runner
|
|
docker compose ps
|
|
# Sollte zeigen: gitea-runner "Up"
|
|
```
|
|
|
|
**Secrets prüfen:**
|
|
```
|
|
https://git.michaelschiemer.de/michael/michaelschiemer/settings/secrets/actions
|
|
```
|
|
- REGISTRY_USER ✅
|
|
- REGISTRY_PASSWORD ✅
|
|
- SSH_PRIVATE_KEY ✅
|
|
|
|
---
|
|
|
|
## 🔍 Was passiert beim Deployment?
|
|
|
|
### Automatischer Ablauf
|
|
|
|
**1. CI/CD Pipeline startet** (bei Push zu `main`)
|
|
- Tests (~2-5 Min)
|
|
- Build (~3-5 Min)
|
|
- Push zur Registry (~1-2 Min)
|
|
|
|
**2. Ansible Deployment** (~2-4 Min)
|
|
- Pre-Flight Checks (Docker läuft, docker-compose.yml existiert)
|
|
- Backup erstellen
|
|
- Registry Login
|
|
- Neues Image pullen
|
|
- docker-compose.yml aktualisieren (Image-Tag ersetzen)
|
|
- Stack neu starten (`--force-recreate`)
|
|
- Health-Checks warten
|
|
|
|
**3. Health-Check** (~1 Min)
|
|
- Application Health-Check
|
|
- Bei Fehler: Automatischer Rollback
|
|
|
|
**Gesamtzeit:** ~8-15 Minuten
|
|
|
|
---
|
|
|
|
## ✅ Erfolgreiches Deployment erkennen
|
|
|
|
### In Gitea Actions
|
|
|
|
```
|
|
https://git.michaelschiemer.de/michael/michaelschiemer/actions
|
|
```
|
|
|
|
**Erfolg:**
|
|
- 🟢 Alle Jobs grün
|
|
- ✅ "Deploy via Ansible" erfolgreich
|
|
- ✅ Health-Check erfolgreich
|
|
|
|
### Auf Production-Server
|
|
|
|
```bash
|
|
# Container-Status
|
|
ssh deploy@94.16.110.151 "cd ~/deployment/stacks/application && docker compose ps"
|
|
|
|
# Application Health-Check
|
|
curl https://michaelschiemer.de/health
|
|
```
|
|
|
|
---
|
|
|
|
## 🆘 Troubleshooting
|
|
|
|
### Problem: "docker-compose.yml not found"
|
|
|
|
**Fehlermeldung:**
|
|
```
|
|
Application Stack docker-compose.yml not found at /home/deploy/deployment/stacks/application/docker-compose.yml
|
|
|
|
The Application Stack must be deployed first via:
|
|
ansible-playbook -i inventory/production.yml playbooks/setup-infrastructure.yml
|
|
```
|
|
|
|
**Lösung:**
|
|
```bash
|
|
cd deployment/ansible
|
|
ansible-playbook -i inventory/production.yml playbooks/setup-infrastructure.yml
|
|
```
|
|
|
|
### Problem: "Failed to pull image"
|
|
|
|
**Lösung:**
|
|
1. Prüfe Registry-Credentials in Gitea Secrets
|
|
2. Teste manuell: `docker login git.michaelschiemer.de:5000`
|
|
3. Prüfe ob Image in Registry vorhanden ist
|
|
|
|
### Problem: "Health-Check failed"
|
|
|
|
**Lösung:**
|
|
- Automatischer Rollback wird ausgeführt
|
|
- Logs prüfen: `docker compose logs app`
|
|
- Manueller Rollback: `ansible-playbook -i inventory/production.yml playbooks/rollback.yml`
|
|
|
|
---
|
|
|
|
## 📚 Weitere Dokumentation
|
|
|
|
- **[QUICK_START.md](QUICK_START.md)** - Schnellstart
|
|
- **[CODE_CHANGE_WORKFLOW.md](CODE_CHANGE_WORKFLOW.md)** - Codeänderungen pushen
|
|
- **[APPLICATION_STACK_DEPLOYMENT.md](APPLICATION_STACK_DEPLOYMENT.md)** - Deployment-Details
|
|
- **[DEPLOYMENT_PREFLIGHT_CHECK.md](DEPLOYMENT_PREFLIGHT_CHECK.md)** - Pre-Flight Checks
|
|
- **[CI_CD_STATUS.md](CI_CD_STATUS.md)** - CI/CD Status
|
|
|
|
---
|
|
|
|
## 🎉 Ready to Deploy!
|
|
|
|
**Alles ist bereit!**
|
|
|
|
**Nächster Schritt:**
|
|
1. **Prüfe ob Application Stack deployed ist** (siehe Pre-Deployment Check oben)
|
|
2. **Falls nicht:** `setup-infrastructure.yml` ausführen
|
|
3. **Dann:** Code pushen und Deployment genießen! 🚀
|
|
|
|
```bash
|
|
git add .
|
|
git commit -m "feat: Add feature"
|
|
git push origin main
|
|
```
|
|
|
|
**Pipeline-Status:**
|
|
```
|
|
https://git.michaelschiemer.de/michael/michaelschiemer/actions
|
|
```
|
|
|
|
---
|
|
|
|
**Viel Erfolg beim ersten Deployment!** 🎉
|