- 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
6.0 KiB
6.0 KiB
✅ Ready to Deploy - Checklist
Stand: 2025-10-31
Status: ✅ Bereit für Code-Deployments!
✅ Vollständig konfiguriert
Infrastructure
- ✅ Traefik (Reverse Proxy & SSL)
- ✅ PostgreSQL (Database)
- ✅ Docker Registry (Private Registry)
- ✅ Gitea (Git Server)
- ✅ Monitoring (Portainer, Grafana, Prometheus)
- ✅ WireGuard VPN
Application Stack
- ✅ Integration in
setup-infrastructure.yml - ✅
.envTemplate (application.env.j2) - ✅ Database-Migration nach Deployment
- ✅ Health-Checks nach Deployment
CI/CD Pipeline
- ✅ Workflows vorhanden (production-deploy.yml)
- ✅ Gitea Runner läuft und ist registriert
- ✅ Secrets konfiguriert (REGISTRY_USER, REGISTRY_PASSWORD, SSH_PRIVATE_KEY)
- ✅ Ansible Playbooks vorhanden
Dokumentation
- ✅ Umfangreiche Guides vorhanden
- ✅ Quick Start Guide
- ✅ Deployment-Dokumentation
🚀 Code deployen - So geht's
Einfachste Methode
# 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
⚠️ Wichtiger Hinweis: Erstmalige Deployment
Wenn Application Stack noch nicht deployed ist:
Der deploy-update.yml Playbook erwartet, dass der Application Stack bereits existiert.
Vor dem ersten Code-Push:
cd deployment/ansible
ansible-playbook -i inventory/production.yml playbooks/setup-infrastructure.yml
Dieses Playbook deployed:
- Alle Infrastructure Stacks (Traefik, PostgreSQL, Registry, Gitea, Monitoring)
- Application Stack (mit docker-compose.yml und .env)
Nach diesem Setup: Ab jetzt funktioniert git push origin main automatisch!
📋 Pre-Deployment Checklist
✅ Alles sollte bereits erledigt sein, aber hier zur Sicherheit:
- Infrastructure Stacks deployed ✅
- Application Stack deployed ⚠️ Prüfen!
- Gitea Runner läuft ✅
- Secrets konfiguriert ✅
- Workflows vorhanden ✅
Application Stack Deployment prüfen
# SSH zum Production-Server
ssh deploy@94.16.110.151
# Prüfe ob Application Stack existiert
test -f ~/deployment/stacks/application/docker-compose.yml && echo "✅ Vorhanden" || echo "❌ Fehlt"
# Prüfe ob .env existiert
test -f ~/deployment/stacks/application/.env && echo "✅ Vorhanden" || echo "❌ Fehlt"
# Prüfe Container-Status
cd ~/deployment/stacks/application
docker compose ps
Falls fehlend: Siehe "Wichtiger Hinweis: Erstmalige Deployment" oben.
🎯 Erster Code-Push
Option 1: Direkt pushen (wenn Stack bereits deployed)
# Test-Commit
echo "# Deployment Test $(date)" >> README.md
git add README.md
git commit -m "test: First deployment via CI/CD pipeline"
git push origin main
# Pipeline beobachten:
# → https://git.michaelschiemer.de/michael/michaelschiemer/actions
Option 2: Application Stack zuerst deployen
# Application Stack deployen (inkl. alle Infrastructure Stacks)
cd deployment/ansible
ansible-playbook -i inventory/production.yml playbooks/setup-infrastructure.yml
# Danach: Ersten Code-Push
git add .
git commit -m "feat: Initial application deployment"
git push origin main
🔍 Was passiert beim Deployment
Pipeline-Ablauf (automatisch):
-
Tests (~2-5 Min)
- PHP Pest Tests
- PHPStan Code Quality
- Code Style Check
-
Build (~3-5 Min)
- Docker Image Build
- Image wird getaggt:
<short-sha>-<timestamp> - Image wird zur Registry gepusht
-
Deploy (~2-4 Min)
- SSH zum Production-Server
- Ansible Playbook wird ausgeführt:
- Backup erstellen
- Registry Login
- Neues Image pullen
- docker-compose.yml aktualisieren
- Stack neu starten
- Health-Checks warten
-
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
# SSH zum Server
ssh deploy@94.16.110.151
# Container-Status prüfen
cd ~/deployment/stacks/application
docker compose ps
# Alle Container sollten "healthy" sein
# Application prüfen
curl https://michaelschiemer.de/health
# Sollte "healthy" zurückgeben
🆘 Troubleshooting
Problem: "docker-compose.yml not found"
Lösung:
# Application Stack zuerst deployen
cd deployment/ansible
ansible-playbook -i inventory/production.yml playbooks/setup-infrastructure.yml
Problem: Pipeline schlägt fehl
Tests fehlgeschlagen:
- Tests lokal ausführen und Fehler beheben
./vendor/bin/pestcomposer cs
Build fehlgeschlagen:
- Docker Build lokal testen
docker build -f Dockerfile.production -t test .
Deployment fehlgeschlagen:
- Logs prüfen: Workflow-Logs in Gitea Actions
- Server-Logs prüfen:
ssh deploy@94.16.110.151 "cd ~/deployment/stacks/application && docker compose logs"
Problem: Health-Check fehlgeschlagen
Automatischer Rollback:
- Pipeline führt automatisch Rollback durch
- Alte Version wird wiederhergestellt
Manueller Rollback:
cd deployment/ansible
ansible-playbook -i inventory/production.yml playbooks/rollback.yml
📚 Weitere Dokumentation
- QUICK_START.md - Schnellstart-Guide
- CODE_CHANGE_WORKFLOW.md - Codeänderungen pushen
- APPLICATION_STACK_DEPLOYMENT.md - Deployment-Details
- CI_CD_STATUS.md - CI/CD Status
🎉 Ready!
Alles ist bereit für Code-Deployments!
Nächster Schritt:
- Prüfe ob Application Stack deployed ist (siehe oben)
- Falls nicht:
setup-infrastructure.ymlausführen - Dann: Code pushen und Deployment genießen! 🚀