# CitySensor Docker Registry Integration ## 🏢 Überblick Diese Konfiguration ist speziell für die **CitySensor Docker Registry** (`docker.citysensor.de`) angepasst und unterstützt: - ✅ **Private Registry Authentication** mit Username/Passwort - ✅ **Automatisches Login** in Build- und Deployment-Skripten - ✅ **Traefik-Integration** für `rezepte.your.domain.com` - ✅ **CI/CD Pipeline** mit GitHub Actions - ✅ **Minimaler Server-Footprint** (~60 KB statt Repository-Clone) ## 🚀 Schnell-Setup ### 1. Build-Konfiguration erstellen: ```bash cp .env.build.example .env.registry # Edit .env.registry mit Ihren CitySensor-Zugangsdaten ``` ### 2. Images bauen und pushen: ```bash ./build-and-push.sh ``` ### 3. Server-Deployment: ```bash # Dateien auf Server kopieren: scp docker-compose.traefik.yml user@server:/opt/rezepte/ scp .env.production user@server:/opt/rezepte/ scp *.sql user@server:/opt/rezepte/ scp deploy-traefik.sh user@server:/opt/rezepte/ # Auf Server deployen: ssh user@server cd /opt/rezepte ./deploy-traefik.sh ``` ## 📁 Konfigurationsdateien ### `.env.registry` (für Build): ```env DOMAIN=example.com API_BASE_URL=https://rezepte.example.com/api DOCKER_REGISTRY=docker.citysensor.de DOCKER_USERNAME=your_username DOCKER_PASSWORD=your_password MYSQL_PASSWORD=secure_db_password MYSQL_ROOT_PASSWORD=super_secure_root_password ``` ### `.env.production` (für Server): ```env DOMAIN=example.com ACME_EMAIL=admin@example.com MYSQL_PASSWORD=secure_db_password MYSQL_ROOT_PASSWORD=super_secure_root_password DOCKER_REGISTRY=docker.citysensor.de DOCKER_USERNAME=your_username DOCKER_PASSWORD=your_password BACKEND_IMAGE=docker.citysensor.de/rezepte-klaus-backend:latest FRONTEND_IMAGE=docker.citysensor.de/rezepte-klaus-frontend:latest ``` ## 🔧 Registry-Authentifizierung ### Manuelles Login: ```bash echo "your_password" | docker login docker.citysensor.de -u your_username --password-stdin ``` ### Automatisches Login: Die Skripte `build-and-push.sh`, `deploy-registry.sh` und `deploy-traefik.sh` führen automatisch ein Login durch, wenn die Umgebungsvariablen gesetzt sind. ## 🌐 DNS-Konfiguration Für `rezepte.example.com` benötigen Sie diese DNS-Einträge: ``` # A-Records auf Ihre Server-IP: rezepte.example.com → 1.2.3.4 traefik.example.com → 1.2.3.4 # Oder Wildcard: *.example.com → 1.2.3.4 ``` ## 🔒 Sicherheitshinweise 1. **Niemals Credentials committen**: `.env.*` Dateien sind in `.gitignore` 2. **Starke Passwörter verwenden**: Besonders für Datenbank und Registry 3. **Traefik Dashboard absichern**: Basic Auth konfiguriert (admin/admin - ändern!) 4. **SSL automatisch**: Let's Encrypt Zertifikate werden automatisch erstellt ## 📊 CI/CD mit GitHub Actions ### Repository Secrets konfigurieren: ``` DOCKER_USERNAME: your_citysensor_username DOCKER_PASSWORD: your_citysensor_password PRODUCTION_API_URL: https://rezepte.example.com/api ``` ### Repository Variables (optional): ``` DOCKER_REGISTRY: docker.citysensor.de ``` ## 🎯 Zugangspunkte nach Deployment - **Hauptanwendung**: https://rezepte.example.com - **Traefik Dashboard**: https://traefik.example.com - **API**: https://rezepte.example.com/api - **Images**: https://rezepte.example.com/uploads/... ## 🛠️ Wartung ### Images aktualisieren: ```bash # Lokal: Neue Images bauen und pushen ./build-and-push.sh # Server: Images pullen und neu starten ./deploy-traefik.sh ``` ### Logs anzeigen: ```bash docker-compose -f docker-compose.traefik.yml logs -f ``` ### Backup: ```bash ./backup.sh ``` ## 🆘 Troubleshooting ### Registry-Login-Probleme: ```bash # Manuell testen: docker login docker.citysensor.de -u username # Credentials prüfen: echo $DOCKER_USERNAME echo $DOCKER_PASSWORD ``` ### SSL-Zertifikat-Probleme: ```bash # DNS prüfen: nslookup rezepte.example.com # Traefik Logs: docker logs traefik ``` ### Container-Probleme: ```bash # Status prüfen: docker-compose -f docker-compose.traefik.yml ps # Logs einzelner Services: docker-compose -f docker-compose.traefik.yml logs backend ``` ## ✅ Checkliste für Go-Live - [ ] DNS-Einträge konfiguriert - [ ] `.env.production` mit korrekten Werten erstellt - [ ] CitySensor Registry-Credentials getestet - [ ] Images erfolgreich gepusht - [ ] Server-Firewall (Ports 80, 443) konfiguriert - [ ] Traefik Dashboard-Passwort geändert - [ ] Backup-Strategie implementiert - [ ] Monitoring eingerichtet Das System ist produktionsreif und skalierbar! 🚀