fix: Gitea Traefik routing and connection pool optimization
Some checks failed
🚀 Build & Deploy Image / Determine Build Necessity (push) Failing after 10m14s
🚀 Build & Deploy Image / Build Runtime Base Image (push) Has been skipped
🚀 Build & Deploy Image / Build Docker Image (push) Has been skipped
🚀 Build & Deploy Image / Run Tests & Quality Checks (push) Has been skipped
🚀 Build & Deploy Image / Auto-deploy to Staging (push) Has been skipped
🚀 Build & Deploy Image / Auto-deploy to Production (push) Has been skipped
Security Vulnerability Scan / Check for Dependency Changes (push) Failing after 11m25s
Security Vulnerability Scan / Composer Security Audit (push) Has been cancelled

- Remove middleware reference from Gitea Traefik labels (caused routing issues)
- Optimize Gitea connection pool settings (MAX_IDLE_CONNS=30, authentication_timeout=180s)
- Add explicit service reference in Traefik labels
- Fix intermittent 504 timeouts by improving PostgreSQL connection handling

Fixes Gitea unreachability via git.michaelschiemer.de
This commit is contained in:
2025-11-09 14:46:15 +01:00
parent 85c369e846
commit 36ef2a1e2c
1366 changed files with 104925 additions and 28719 deletions

View File

@@ -0,0 +1,298 @@
# CI/CD Pipeline Testing Guide
**Stand:** 2025-11-07
**Status:** Anleitung für End-to-End Pipeline-Tests
---
## Übersicht
Dieses Dokument erklärt, wie die CI/CD Pipeline getestet wird. Die Tests sollten sowohl für Staging als auch für Production durchgeführt werden.
**📖 Verwandte Dokumentation:**
- [Pipeline Test Checklist](./pipeline-test-checklist.md) ⭐ - Detaillierte Schritt-für-Schritt Checkliste
- [CI/CD Workflow Guide](./cicd-workflow-guide.md) - Workflow-Dokumentation
- [CI/CD Status](../status/ci-cd-status.md) - Aktueller Status
- [Troubleshooting Guide](../troubleshooting/initial-deployment-issues.md) - Probleme und Lösungen
**🔧 Test-Scripts:**
- `deployment/scripts/test-pipeline-prerequisites.sh` - Prüft alle Voraussetzungen für Pipeline-Tests
---
## Voraussetzungen prüfen
**Schnellcheck mit Script:**
```bash
cd /home/michael/dev/michaelschiemer
./deployment/scripts/test-pipeline-prerequisites.sh
```
Dieses Script prüft automatisch alle Voraussetzungen und gibt eine Zusammenfassung aus.
### 1. Secrets konfiguriert
**Erforderliche Secrets in Gitea:**
-`REGISTRY_USER` - Docker Registry Benutzername
-`REGISTRY_PASSWORD` - Docker Registry Passwort
-`SSH_PRIVATE_KEY` - SSH Private Key für Production-Server
-`ANSIBLE_VAULT_PASSWORD` - Ansible Vault Password
**Prüfen:**
```
https://git.michaelschiemer.de/michael/michaelschiemer/settings/secrets/actions
```
### 2. Gitea Runner läuft
**Prüfen:**
```bash
cd deployment/gitea-runner
docker compose ps
```
**Erwartet:**
- `gitea-runner`: Up
- `gitea-runner-dind`: Up
**In Gitea UI prüfen:**
```
https://git.michaelschiemer.de/admin/actions/runners
```
Runner sollte als "Idle" oder "Active" angezeigt werden.
### 3. Application Stack läuft
**Prüfen:**
```bash
ssh deploy@94.16.110.151
cd ~/deployment/stacks/production
docker compose -f docker-compose.base.yml -f docker-compose.production.yml ps
```
**Erwartet:**
- Alle Container: Up (healthy)
---
## Staging Pipeline Test
### Schritt 1: Test-Commit erstellen
```bash
# Auf staging Branch
git checkout staging
git pull origin staging
# Kleine Änderung
echo "# Test CI/CD Pipeline - $(date)" >> README.md
git add README.md
git commit -m "test: CI/CD pipeline test"
git push origin staging
```
### Schritt 2: Pipeline beobachten
**Gitea Actions UI:**
```
https://git.michaelschiemer.de/michael/michaelschiemer/actions
```
**Erwartete Jobs:**
1. **changes** - Prüft ob Build notwendig ist
2. **test** - Führt Tests aus
3. **build** - Baut Docker Image
4. **deploy-staging** - Deploy zu Staging
### Schritt 3: Verifikation
**Code-Deployment:**
```bash
ssh deploy@94.16.110.151
cd /home/deploy/michaelschiemer/current
git log -1 # Sollte Test-Commit zeigen
```
**Composer Dependencies:**
```bash
docker compose -f docker-compose.base.yml -f docker-compose.production.yml \
exec php test -f /var/www/html/vendor/autoload.php && echo "EXISTS"
```
**Image-Deployment:**
```bash
docker compose -f docker-compose.base.yml -f docker-compose.production.yml \
ps # Container sollten mit neuem Image laufen
```
**Health-Check:**
```bash
curl -f https://staging.michaelschiemer.de/health
```
### Schritt 4: Fehler beheben
**Falls Fehler auftreten:**
1. Logs in Gitea Actions UI prüfen
2. Container Logs prüfen: `docker compose logs`
3. Siehe [Troubleshooting Guide](../troubleshooting/initial-deployment-issues.md)
---
## Production Pipeline Test
### Schritt 1: Test-Commit erstellen
**Wichtig:** Nur nach erfolgreichem Staging-Test!
```bash
# Auf main Branch
git checkout main
git pull origin main
# Merge staging (oder direkter Commit für Test)
echo "# Test CI/CD Pipeline Production - $(date)" >> README.md
git add README.md
git commit -m "test: CI/CD pipeline production test"
git push origin main
```
### Schritt 2: Pipeline beobachten
**Gitea Actions UI:**
```
https://git.michaelschiemer.de/michael/michaelschiemer/actions
```
**Erwartete Jobs:**
1. **changes** - Prüft ob Build notwendig ist
2. **test** - Führt Tests aus
3. **build** - Baut Docker Image
4. **deploy-production** - Deploy zu Production
### Schritt 3: Verifikation
**Gleiche Checks wie Staging:**
- Code-Deployment verifizieren
- Composer Dependencies verifizieren
- Image-Deployment verifizieren
- Health-Check durchführen
**Production URL:**
```bash
curl -f https://michaelschiemer.de/health
```
### Schritt 4: Rollback-Test (Optional)
**Falls Deployment fehlschlägt:**
```bash
cd deployment/ansible
ansible-playbook -i inventory/production.yml \
playbooks/rollback.yml \
--vault-password-file secrets/.vault_pass
```
---
## Manueller Workflow-Test
### Via Gitea UI
**Schritte:**
1. Gehe zu: `https://git.michaelschiemer.de/michael/michaelschiemer/actions`
2. Wähle: "Manual Deployment"
3. Klicke: "Run workflow"
4. Wähle:
- Environment: `staging` oder `production`
- Image Tag: Optional (z.B. `latest` oder `git-abc1234`)
- Branch: Optional
5. Klicke: "Run workflow"
6. Beobachte Logs
---
## Checkliste für erfolgreichen Test
### Staging Test
- [ ] Test-Commit gepusht
- [ ] Pipeline gestartet
- [ ] Alle Jobs erfolgreich:
- [ ] changes
- [ ] test
- [ ] build
- [ ] deploy-staging
- [ ] Code-Deployment erfolgreich
- [ ] Composer Dependencies installiert
- [ ] Image-Deployment erfolgreich
- [ ] Health-Check erfolgreich
- [ ] Application läuft korrekt
### Production Test
- [ ] Staging Test erfolgreich
- [ ] Test-Commit auf main gepusht
- [ ] Pipeline gestartet
- [ ] Alle Jobs erfolgreich:
- [ ] changes
- [ ] test
- [ ] build
- [ ] deploy-production
- [ ] Code-Deployment erfolgreich
- [ ] Composer Dependencies installiert
- [ ] Image-Deployment erfolgreich
- [ ] Health-Check erfolgreich
- [ ] Application läuft korrekt
---
## Bekannte Probleme & Workarounds
### Problem: Pipeline startet nicht
**Ursache:** Runner läuft nicht oder ist nicht registriert
**Lösung:**
```bash
cd deployment/gitea-runner
docker compose restart gitea-runner
# Prüfe Runner-Status in Gitea UI
```
### Problem: Code-Deployment schlägt fehl
**Ursache:** Git Repository existiert nicht auf Server
**Lösung:**
```bash
# Initial Deployment durchführen
ansible-playbook -i inventory/production.yml \
playbooks/sync-application-code.yml \
--vault-password-file secrets/.vault_pass
```
### Problem: Image-Deployment schlägt fehl
**Ursache:** Registry Login fehlgeschlagen
**Lösung:**
- Prüfe `REGISTRY_USER` und `REGISTRY_PASSWORD` Secrets
- Teste Registry Login manuell
### Problem: Health-Check schlägt fehl
**Ursache:** Container starten nicht oder Application hat Fehler
**Lösung:**
- Prüfe Container Status
- Prüfe Container Logs
- Siehe [Troubleshooting Guide](../troubleshooting/initial-deployment-issues.md)
---
## Referenz
- [CI/CD Workflow Guide](./cicd-workflow-guide.md) - Workflow-Dokumentation
- [CI/CD Status](../status/ci-cd-status.md) - Aktueller Status
- [Troubleshooting Guide](../troubleshooting/initial-deployment-issues.md) - Probleme und Lösungen
- [Backup & Rollback Guide](./backup-and-rollback-guide.md) - Rollback-Prozess