chore: sync staging workspace
This commit is contained in:
239
deployment/docs/tests/git-deployment-test.md
Normal file
239
deployment/docs/tests/git-deployment-test.md
Normal file
@@ -0,0 +1,239 @@
|
||||
# Git-basiertes Deployment - Test Plan
|
||||
|
||||
**Datum:** 2025-01-31
|
||||
**Status:** ⏳ Ready to Test
|
||||
|
||||
---
|
||||
|
||||
## 🎯 Ziel
|
||||
|
||||
Testen, ob Container automatisch Code aus Git-Repository klont/pullt beim Start.
|
||||
|
||||
---
|
||||
|
||||
## ✅ Vorbereitung
|
||||
|
||||
### 1. Prüfen ob alles korrekt konfiguriert ist
|
||||
|
||||
#### Docker Entrypoint
|
||||
- ✅ `docker/entrypoint.sh` - Git Clone/Pull implementiert
|
||||
- ✅ `Dockerfile.production` - Git + Composer installiert
|
||||
|
||||
#### Docker Compose
|
||||
- ✅ `deployment/stacks/application/docker-compose.yml` - Git Environment Variables vorhanden
|
||||
|
||||
#### Ansible Playbook
|
||||
- ✅ `deployment/ansible/playbooks/sync-code.yml` - Erstellt
|
||||
|
||||
---
|
||||
|
||||
## 🧪 Test-Plan
|
||||
|
||||
### Test 1: Git-Variablen in .env setzen
|
||||
|
||||
**Ziel:** Prüfen ob Git-Konfiguration in .env gesetzt werden kann
|
||||
|
||||
```bash
|
||||
# SSH zum Production-Server
|
||||
ssh deploy@94.16.110.151
|
||||
|
||||
# Prüfen ob .env existiert
|
||||
cd ~/deployment/stacks/application
|
||||
test -f .env && echo "✅ OK" || echo "❌ Fehlt"
|
||||
|
||||
# Git-Variablen manuell hinzufügen (für Test)
|
||||
cat >> .env << 'EOF'
|
||||
|
||||
# Git Repository Configuration
|
||||
GIT_REPOSITORY_URL=https://git.michaelschiemer.de/michael/michaelschiemer.git
|
||||
GIT_BRANCH=main
|
||||
GIT_TOKEN=
|
||||
EOF
|
||||
```
|
||||
|
||||
**Erwartetes Ergebnis:**
|
||||
- ✅ .env existiert
|
||||
- ✅ Git-Variablen können hinzugefügt werden
|
||||
|
||||
---
|
||||
|
||||
### Test 2: Container mit Git-Variablen starten
|
||||
|
||||
**Ziel:** Prüfen ob Container Git Clone/Pull beim Start ausführt
|
||||
|
||||
```bash
|
||||
# Auf Production-Server
|
||||
cd ~/deployment/stacks/application
|
||||
|
||||
# Container neu starten
|
||||
docker compose restart app
|
||||
|
||||
# Logs prüfen (sollte Git Clone/Pull zeigen)
|
||||
docker logs app --tail 100 | grep -E "(Git|Clone|Pull|✅|❌)"
|
||||
```
|
||||
|
||||
**Erwartetes Ergebnis:**
|
||||
- ✅ Logs zeigen "📥 Cloning/Pulling code from Git repository..."
|
||||
- ✅ Logs zeigen "📥 Cloning repository from ..." oder "🔄 Pulling latest changes..."
|
||||
- ✅ Logs zeigen "✅ Git sync completed"
|
||||
|
||||
**Falls Fehler:**
|
||||
- ❌ Logs zeigen Fehler → Troubleshooting nötig
|
||||
- ❌ Keine Git-Logs → Entrypoint nicht korrekt oder Git-Variablen nicht gesetzt
|
||||
|
||||
---
|
||||
|
||||
### Test 3: Code-Verifikation im Container
|
||||
|
||||
**Ziel:** Prüfen ob Code tatsächlich im Container ist
|
||||
|
||||
```bash
|
||||
# Auf Production-Server
|
||||
docker exec app ls -la /var/www/html/ | head -20
|
||||
docker exec app test -f /var/www/html/composer.json && echo "✅ composer.json vorhanden" || echo "❌ Fehlt"
|
||||
docker exec app test -d /var/www/html/src && echo "✅ src/ vorhanden" || echo "❌ Fehlt"
|
||||
docker exec app test -d /var/www/html/.git && echo "✅ .git vorhanden" || echo "❌ Fehlt"
|
||||
```
|
||||
|
||||
**Erwartetes Ergebnis:**
|
||||
- ✅ Dateien sind im Container
|
||||
- ✅ `.git` Verzeichnis existiert (zeigt dass Git Clone funktioniert hat)
|
||||
|
||||
---
|
||||
|
||||
### Test 4: Code-Update testen (Git Pull)
|
||||
|
||||
**Ziel:** Prüfen ob `sync-code.yml` Playbook funktioniert
|
||||
|
||||
```bash
|
||||
# Lokal (auf Dev-Machine)
|
||||
cd deployment/ansible
|
||||
|
||||
# Sync-Code Playbook ausführen
|
||||
ansible-playbook -i inventory/production.yml \
|
||||
playbooks/sync-code.yml \
|
||||
-e "git_branch=main"
|
||||
|
||||
# Container-Logs prüfen (auf Production-Server)
|
||||
ssh deploy@94.16.110.151
|
||||
docker logs app --tail 50 | grep -E "(Git|Pull|✅)"
|
||||
```
|
||||
|
||||
**Erwartetes Ergebnis:**
|
||||
- ✅ Playbook führt erfolgreich aus
|
||||
- ✅ Container wird neu gestartet
|
||||
- ✅ Logs zeigen "🔄 Pulling latest changes..."
|
||||
- ✅ Code wird aktualisiert
|
||||
|
||||
---
|
||||
|
||||
### Test 5: Application Health Check
|
||||
|
||||
**Ziel:** Prüfen ob Application nach Git-Sync noch funktioniert
|
||||
|
||||
```bash
|
||||
# Health Check
|
||||
curl -f https://michaelschiemer.de/health || echo "❌ Health Check fehlgeschlagen"
|
||||
|
||||
# Application Test
|
||||
curl -f https://michaelschiemer.de/ || echo "❌ Application fehlgeschlagen"
|
||||
```
|
||||
|
||||
**Erwartetes Ergebnis:**
|
||||
- ✅ Health Check erfolgreich
|
||||
- ✅ Application läuft
|
||||
|
||||
---
|
||||
|
||||
## 🔧 Troubleshooting
|
||||
|
||||
### Problem: Container zeigt keine Git-Logs
|
||||
|
||||
**Mögliche Ursachen:**
|
||||
1. `GIT_REPOSITORY_URL` nicht in .env gesetzt
|
||||
2. Entrypoint Script nicht korrekt
|
||||
3. Git nicht im Container installiert
|
||||
|
||||
**Lösung:**
|
||||
```bash
|
||||
# Prüfen .env
|
||||
cd ~/deployment/stacks/application
|
||||
grep GIT_REPOSITORY_URL .env
|
||||
|
||||
# Prüfen Entrypoint
|
||||
docker exec app cat /usr/local/bin/entrypoint.sh | grep -A 10 "GIT_REPOSITORY_URL"
|
||||
|
||||
# Prüfen Git Installation
|
||||
docker exec app which git
|
||||
docker exec app git --version
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Problem: Git Clone fehlgeschlagen
|
||||
|
||||
**Mögliche Ursachen:**
|
||||
1. Repository nicht erreichbar vom Server
|
||||
2. Falsche Credentials
|
||||
3. Branch nicht existiert
|
||||
|
||||
**Lösung:**
|
||||
```bash
|
||||
# Prüfen Repository-Zugriff
|
||||
docker exec app git clone --branch main --depth 1 https://git.michaelschiemer.de/michael/michaelschiemer.git /tmp/test-clone
|
||||
|
||||
# Logs prüfen
|
||||
docker logs app --tail 100 | grep -i "error\|fail"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Problem: Composer Install fehlgeschlagen
|
||||
|
||||
**Mögliche Ursachen:**
|
||||
1. Composer nicht installiert
|
||||
2. Network-Probleme beim Dependency-Download
|
||||
|
||||
**Lösung:**
|
||||
```bash
|
||||
# Composer prüfen
|
||||
docker exec app which composer
|
||||
docker exec app composer --version
|
||||
|
||||
# Manuell testen
|
||||
docker exec app sh -c "cd /var/www/html && composer install --no-dev --optimize-autoloader --no-interaction"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 📋 Checkliste für Test
|
||||
|
||||
### Vor Test:
|
||||
- [ ] Git-Repository ist erreichbar vom Production-Server
|
||||
- [ ] Git-Credentials sind verfügbar (falls private Repository)
|
||||
- [ ] .env Datei existiert auf Production-Server
|
||||
- [ ] Container-Image wurde neu gebaut (mit Git + Composer)
|
||||
|
||||
### Während Test:
|
||||
- [ ] Test 1: Git-Variablen in .env setzen
|
||||
- [ ] Test 2: Container mit Git-Variablen starten
|
||||
- [ ] Test 3: Code-Verifikation im Container
|
||||
- [ ] Test 4: Code-Update testen (Git Pull)
|
||||
- [ ] Test 5: Application Health Check
|
||||
|
||||
### Nach Test:
|
||||
- [ ] Alle Tests erfolgreich
|
||||
- [ ] Application läuft korrekt
|
||||
- [ ] Code ist aktuell
|
||||
|
||||
---
|
||||
|
||||
## 🚀 Nächste Schritte nach erfolgreichem Test
|
||||
|
||||
1. ✅ Git-basiertes Deployment dokumentieren
|
||||
2. ✅ In CI/CD Pipeline integrieren (optional)
|
||||
3. ✅ Dokumentation aktualisieren
|
||||
|
||||
---
|
||||
|
||||
**Bereit zum Testen!** 🧪
|
||||
Reference in New Issue
Block a user