- Replace git.michaelschiemer.de:5000 (HTTP) with registry.michaelschiemer.de (HTTPS) - Update all Ansible playbooks and configuration files - Update CI/CD workflows to use HTTPS registry endpoint - Update Docker Compose files with new registry URL - Update documentation and scripts Benefits: - Secure HTTPS connection (no insecure registry config needed) - Consistent use of HTTPS endpoint via Traefik - Better security practices for production deployment
145 lines
3.3 KiB
Markdown
145 lines
3.3 KiB
Markdown
# 🎯 Empfohlener Test-Workflow für Git-Deployment
|
|
|
|
## Meine Empfehlung: **Schritt-für-Schritt mit Checks**
|
|
|
|
### Warum?
|
|
- ✅ Minimiert Risiko von Fehlern
|
|
- ✅ Erlaubt Verifikation nach jedem Schritt
|
|
- ✅ Einfaches Rollback bei Problemen
|
|
- ✅ Klare Fehlerdiagnose
|
|
|
|
---
|
|
|
|
## 📋 Workflow
|
|
|
|
### Schritt 1: Image pushen (falls nötig)
|
|
|
|
**Wann nötig?**
|
|
- Wenn Production-Server das Image aus der Registry zieht
|
|
- Wenn Image lokal gebaut wurde und noch nicht gepusht
|
|
|
|
**Befehl:**
|
|
```bash
|
|
# Im Projekt-Root
|
|
docker push registry.michaelschiemer.de/framework:latest
|
|
```
|
|
|
|
**Check:**
|
|
```bash
|
|
# Prüfen ob Image in Registry ist (optional)
|
|
curl -k https://registry.michaelschiemer.de/v2/framework/tags/list
|
|
```
|
|
|
|
---
|
|
|
|
### Schritt 2: Git-Variablen setzen (via Ansible)
|
|
|
|
**Warum Ansible?**
|
|
- ✅ Automatisiert und reproduzierbar
|
|
- ✅ Aktualisiert .env korrekt
|
|
- ✅ Startet Container automatisch neu
|
|
|
|
**Befehl:**
|
|
```bash
|
|
cd deployment/ansible
|
|
|
|
ansible-playbook -i inventory/production.yml \
|
|
playbooks/sync-code.yml \
|
|
-e "git_repo_url=https://git.michaelschiemer.de/michael/michaelschiemer.git" \
|
|
-e "git_branch=main"
|
|
```
|
|
|
|
**Was passiert?**
|
|
1. .env Datei wird mit Git-Variablen aktualisiert
|
|
2. Container wird neu gestartet
|
|
3. Entrypoint führt Git Clone/Pull aus
|
|
4. Logs werden angezeigt
|
|
|
|
---
|
|
|
|
### Schritt 3: Logs prüfen
|
|
|
|
**Auf Production Server:**
|
|
```bash
|
|
ssh deploy@94.16.110.151
|
|
|
|
# Logs mit Git-Filter
|
|
docker logs app --tail 100 | grep -E "(Git|Clone|Pull|✅|❌)"
|
|
|
|
# Oder vollständige Logs
|
|
docker logs app --tail 50
|
|
```
|
|
|
|
**Erwartete Logs:**
|
|
```
|
|
📥 Cloning/Pulling code from Git repository...
|
|
📥 Cloning repository from https://git.michaelschiemer.de/... (branch: main)
|
|
📦 Installing/updating Composer dependencies...
|
|
✅ Git sync completed
|
|
```
|
|
|
|
---
|
|
|
|
### Schritt 4: Code-Verifikation
|
|
|
|
**Prüfen ob Code im Container ist:**
|
|
```bash
|
|
docker exec app ls -la /var/www/html/ | head -20
|
|
docker exec app test -d /var/www/html/.git && echo "✅ Git repo vorhanden" || echo "❌ Fehlt"
|
|
docker exec app test -f /var/www/html/composer.json && echo "✅ composer.json vorhanden" || echo "❌ Fehlt"
|
|
```
|
|
|
|
---
|
|
|
|
### Schritt 5: Application Health Check
|
|
|
|
```bash
|
|
curl -f https://michaelschiemer.de/health || echo "❌ Health Check fehlgeschlagen"
|
|
```
|
|
|
|
---
|
|
|
|
## 🎯 Mein konkreter Vorschlag
|
|
|
|
**Starte mit Schritt 2** (Git-Variablen setzen via Ansible), weil:
|
|
|
|
1. **Ansible prüft automatisch**, ob alles vorhanden ist
|
|
2. **Startet Container automatisch** neu
|
|
3. **Zeigt Logs direkt** an
|
|
4. **Minimaler Aufwand** - ein Befehl
|
|
|
|
Falls das Image noch nicht in der Registry ist, wird der Container automatisch das neue Image ziehen beim `docker compose up`.
|
|
|
|
---
|
|
|
|
## 🚨 Alternative: Lokaler Test (falls gewünscht)
|
|
|
|
Falls du erst lokal testen möchtest:
|
|
|
|
```bash
|
|
# Lokal Container starten mit Git-Variablen
|
|
cd deployment/stacks/application
|
|
|
|
# .env erstellen/kopieren
|
|
cp .env.example .env
|
|
|
|
# Git-Variablen hinzufügen
|
|
echo "" >> .env
|
|
echo "GIT_REPOSITORY_URL=https://git.michaelschiemer.de/michael/michaelschiemer.git" >> .env
|
|
echo "GIT_BRANCH=main" >> .env
|
|
|
|
# Container starten
|
|
docker compose up -d app
|
|
|
|
# Logs prüfen
|
|
docker compose logs app | grep -E "(Git|Clone|Pull)"
|
|
```
|
|
|
|
---
|
|
|
|
## ✅ Entscheidung
|
|
|
|
**Meine Empfehlung:** Starte mit **Schritt 2** (Ansible Playbook). Das ist der sauberste und sicherste Weg.
|
|
|
|
Soll ich das für dich ausführen?
|