# ✅ 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` - ✅ `.env` Template (`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 ```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` --- ## ⚠️ 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:** ```bash 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: - [x] Infrastructure Stacks deployed ✅ - [ ] **Application Stack deployed** ⚠️ Prüfen! - [x] Gitea Runner läuft ✅ - [x] Secrets konfiguriert ✅ - [x] Workflows vorhanden ✅ ### Application Stack Deployment prüfen ```bash # 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) ```bash # 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 ```bash # 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): 1. **Tests** (~2-5 Min) - PHP Pest Tests - PHPStan Code Quality - Code Style Check 2. **Build** (~3-5 Min) - Docker Image Build - Image wird getaggt: `-` - Image wird zur Registry gepusht 3. **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 4. **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 # 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:** ```bash # 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/pest` - `composer 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:** ```bash cd deployment/ansible ansible-playbook -i inventory/production.yml playbooks/rollback.yml ``` --- ## 📚 Weitere Dokumentation - **[QUICK_START.md](QUICK_START.md)** - Schnellstart-Guide - **[CODE_CHANGE_WORKFLOW.md](CODE_CHANGE_WORKFLOW.md)** - Codeänderungen pushen - **[APPLICATION_STACK_DEPLOYMENT.md](APPLICATION_STACK_DEPLOYMENT.md)** - Deployment-Details - **[CI_CD_STATUS.md](CI_CD_STATUS.md)** - CI/CD Status --- ## 🎉 Ready! **Alles ist bereit für Code-Deployments!** **Nächster Schritt:** 1. Prüfe ob Application Stack deployed ist (siehe oben) 2. Falls nicht: `setup-infrastructure.yml` ausführen 3. Dann: Code pushen und Deployment genießen! 🚀