- 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
164 lines
3.3 KiB
Markdown
164 lines
3.3 KiB
Markdown
# Deployment Pre-Flight Check
|
|
|
|
**Bevor du Code pushen kannst, prüfe diese Checkliste!**
|
|
|
|
---
|
|
|
|
## ✅ Kritische Prüfungen
|
|
|
|
### 1. Application Stack muss deployed sein
|
|
|
|
**Warum kritisch:**
|
|
- `deploy-update.yml` erwartet, dass `docker-compose.yml` bereits existiert
|
|
- `.env` File muss vorhanden sein für Container-Konfiguration
|
|
|
|
**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"
|
|
|
|
# Prüfe .env
|
|
test -f ~/deployment/stacks/application/.env && echo "✅ OK" || echo "❌ FEHLT"
|
|
|
|
# Prüfe Container
|
|
cd ~/deployment/stacks/application
|
|
docker compose ps
|
|
```
|
|
|
|
**Falls fehlend:**
|
|
```bash
|
|
cd deployment/ansible
|
|
ansible-playbook -i inventory/production.yml playbooks/setup-infrastructure.yml
|
|
```
|
|
|
|
### 2. Docker Registry muss erreichbar sein
|
|
|
|
**Prüfen:**
|
|
```bash
|
|
# Vom Production-Server
|
|
ssh deploy@94.16.110.151
|
|
docker login git.michaelschiemer.de:5000 -u admin -p <password>
|
|
|
|
# Oder Test-Pull
|
|
docker pull git.michaelschiemer.de:5000/framework:latest
|
|
```
|
|
|
|
### 3. Gitea Runner muss laufen
|
|
|
|
**Prüfen:**
|
|
```bash
|
|
cd deployment/gitea-runner
|
|
docker compose ps
|
|
# Sollte zeigen: gitea-runner "Up"
|
|
```
|
|
|
|
**In Gitea UI:**
|
|
```
|
|
https://git.michaelschiemer.de/admin/actions/runners
|
|
```
|
|
- Runner sollte als "Idle" oder "Active" angezeigt werden
|
|
|
|
### 4. Secrets müssen konfiguriert sein
|
|
|
|
**In Gitea:**
|
|
```
|
|
https://git.michaelschiemer.de/michael/michaelschiemer/settings/secrets/actions
|
|
```
|
|
|
|
**Prüfen:**
|
|
- [ ] `REGISTRY_USER` vorhanden
|
|
- [ ] `REGISTRY_PASSWORD` vorhanden
|
|
- [ ] `SSH_PRIVATE_KEY` vorhanden
|
|
|
|
### 5. SSH-Zugriff muss funktionieren
|
|
|
|
**Prüfen:**
|
|
```bash
|
|
# Test SSH-Verbindung
|
|
ssh -i ~/.ssh/production deploy@94.16.110.151 "echo 'SSH OK'"
|
|
```
|
|
|
|
---
|
|
|
|
## 🧪 Pre-Deployment Test
|
|
|
|
### Test 1: Ansible-Verbindung
|
|
|
|
```bash
|
|
cd deployment/ansible
|
|
ansible -i inventory/production.yml production -m ping
|
|
# Sollte: production | SUCCESS
|
|
```
|
|
|
|
### Test 2: Application Stack Status
|
|
|
|
```bash
|
|
cd deployment/ansible
|
|
ansible -i inventory/production.yml production -a "test -f ~/deployment/stacks/application/docker-compose.yml && echo 'OK' || echo 'MISSING'"
|
|
# Sollte: "OK"
|
|
```
|
|
|
|
### Test 3: Docker Registry Login (vom Runner aus)
|
|
|
|
```bash
|
|
# Vom Development-Machine (wo Runner läuft)
|
|
docker login git.michaelschiemer.de:5000 -u <registry-user> -p <registry-password>
|
|
# Sollte: Login Succeeded
|
|
```
|
|
|
|
---
|
|
|
|
## ⚠️ Häufige Probleme
|
|
|
|
### Problem: "Application Stack nicht deployed"
|
|
|
|
**Symptom:**
|
|
- `docker-compose.yml not found` Fehler
|
|
|
|
**Lösung:**
|
|
```bash
|
|
cd deployment/ansible
|
|
ansible-playbook -i inventory/production.yml playbooks/setup-infrastructure.yml
|
|
```
|
|
|
|
### Problem: "Registry Login fehlschlägt"
|
|
|
|
**Symptom:**
|
|
- `unauthorized: authentication required`
|
|
|
|
**Lösung:**
|
|
1. Prüfe Secrets in Gitea
|
|
2. Prüfe Registry-Credentials
|
|
3. Teste manuell: `docker login git.michaelschiemer.de:5000`
|
|
|
|
### Problem: "SSH-Verbindung fehlschlägt"
|
|
|
|
**Symptom:**
|
|
- Ansible kann nicht zum Server verbinden
|
|
|
|
**Lösung:**
|
|
1. Prüfe SSH Key: `~/.ssh/production`
|
|
2. Prüfe SSH Config
|
|
3. Teste manuell: `ssh -i ~/.ssh/production deploy@94.16.110.151`
|
|
|
|
---
|
|
|
|
## ✅ Alles OK? Dann los!
|
|
|
|
```bash
|
|
git add .
|
|
git commit -m "feat: Add feature"
|
|
git push origin main
|
|
```
|
|
|
|
**Pipeline-Status:**
|
|
```
|
|
https://git.michaelschiemer.de/michael/michaelschiemer/actions
|
|
```
|
|
|
|
---
|
|
|
|
**Viel Erfolg!** 🚀
|