Docker mit traefik und portainer
This commit is contained in:
196
DOCKER_SETUP.md
Normal file
196
DOCKER_SETUP.md
Normal file
@@ -0,0 +1,196 @@
|
||||
# Rezepte Klaus - Docker Deployment
|
||||
|
||||
Dieses Projekt kann komplett über Docker containerisiert betrieben werden.
|
||||
|
||||
## Voraussetzungen
|
||||
|
||||
- Docker Desktop installiert und gestartet
|
||||
- mindestens 4GB freier RAM
|
||||
- mindestens 2GB freier Festplattenspeicher
|
||||
|
||||
## Quick Start
|
||||
|
||||
```bash
|
||||
# 1. Repository klonen/herunterladen
|
||||
git clone <repository-url>
|
||||
cd Rezepte_Klaus
|
||||
|
||||
# 2. Docker Deployment starten
|
||||
./docker-deploy.sh
|
||||
|
||||
# 3. Warten bis alle Services bereit sind
|
||||
# Das Script zeigt den Fortschritt an
|
||||
|
||||
# 4. Services nutzen:
|
||||
# - Frontend: http://localhost:3000
|
||||
# - Backend API: http://localhost:3001
|
||||
# - phpMyAdmin: http://localhost:8080
|
||||
# - Legacy PHP: http://localhost:8090 (optional)
|
||||
```
|
||||
|
||||
## Services stoppen
|
||||
|
||||
```bash
|
||||
./docker-stop.sh
|
||||
```
|
||||
|
||||
## Architektur
|
||||
|
||||
Das Docker-Setup besteht aus folgenden Services:
|
||||
|
||||
### Frontend (Port 3000)
|
||||
- React/TypeScript Anwendung
|
||||
- Nginx Web Server
|
||||
- Optimiert für Produktion mit Caching
|
||||
|
||||
### Backend (Port 3001)
|
||||
- Node.js/Express API
|
||||
- Prisma ORM für Database
|
||||
- Multer für File Uploads
|
||||
- Health Checks
|
||||
|
||||
### Database (Port 3306)
|
||||
- MySQL 8.0
|
||||
- Persistente Datenspeicherung
|
||||
- Automatische Health Checks
|
||||
|
||||
### phpMyAdmin (Port 8080)
|
||||
- Web-Interface für MySQL
|
||||
- Benutzer: recipes_user
|
||||
- Passwort: recipes_password_2024
|
||||
|
||||
### Legacy PHP (Port 8090) - Optional
|
||||
- Bestehende PHP-Anwendung
|
||||
- Für Migration und Kompatibilität
|
||||
|
||||
## Volumes & Persistenz
|
||||
|
||||
```bash
|
||||
docker-data/
|
||||
├── mysql/ # Database Dateien
|
||||
├── uploads/ # Hochgeladene Bilder
|
||||
└── logs/ # Application Logs
|
||||
```
|
||||
|
||||
## Environment Configuration
|
||||
|
||||
Die Konfiguration erfolgt über `.env` Dateien:
|
||||
|
||||
- `.env.docker` - Produktion (Docker)
|
||||
- `.env.development` - Entwicklung (lokal)
|
||||
|
||||
## Debugging
|
||||
|
||||
```bash
|
||||
# Container Logs anzeigen
|
||||
docker-compose -f docker-compose.modern.yml logs -f
|
||||
|
||||
# Specific Service Logs
|
||||
docker-compose -f docker-compose.modern.yml logs -f backend
|
||||
docker-compose -f docker-compose.modern.yml logs -f frontend
|
||||
|
||||
# In Container einloggen
|
||||
docker-compose -f docker-compose.modern.yml exec backend bash
|
||||
docker-compose -f docker-compose.modern.yml exec frontend sh
|
||||
|
||||
# Container Status prüfen
|
||||
docker-compose -f docker-compose.modern.yml ps
|
||||
|
||||
# Services neustarten
|
||||
docker-compose -f docker-compose.modern.yml restart backend
|
||||
```
|
||||
|
||||
## Development
|
||||
|
||||
Für lokale Entwicklung:
|
||||
|
||||
```bash
|
||||
# Development Environment nutzen
|
||||
cp .env.development .env
|
||||
|
||||
# Backend starten
|
||||
cd nodejs-version/backend
|
||||
npm install
|
||||
npm run dev
|
||||
|
||||
# Frontend starten
|
||||
cd frontend
|
||||
npm install
|
||||
npm run dev
|
||||
```
|
||||
|
||||
## Migration von Legacy System
|
||||
|
||||
Das Docker-Setup migriert automatisch:
|
||||
|
||||
1. Bestehende Uploads aus `upload/` nach `docker-data/uploads/`
|
||||
2. Database Schema über Prisma Migrations
|
||||
3. Legacy PHP bleibt parallel verfügbar
|
||||
|
||||
## Security Features
|
||||
|
||||
- Non-root Container User
|
||||
- Security Headers (CSP, HSTS, etc.)
|
||||
- File Upload Validation
|
||||
- Network Isolation
|
||||
- Health Checks für alle Services
|
||||
|
||||
## Performance Optimization
|
||||
|
||||
- Multi-stage Docker Builds
|
||||
- Nginx Gzip Compression
|
||||
- Static Asset Caching
|
||||
- Database Connection Pooling
|
||||
- Upload Size Limits
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Port bereits belegt
|
||||
```bash
|
||||
# Prüfe welche Ports belegt sind
|
||||
lsof -i :3000
|
||||
lsof -i :3001
|
||||
|
||||
# Ändere Ports in .env wenn nötig
|
||||
FRONTEND_PORT=3010
|
||||
BACKEND_PORT=3011
|
||||
```
|
||||
|
||||
### Upload Probleme
|
||||
```bash
|
||||
# Prüfe Upload-Berechtigungen
|
||||
ls -la docker-data/uploads/
|
||||
|
||||
# Upload Ordner neu erstellen
|
||||
docker-compose -f docker-compose.modern.yml exec backend mkdir -p /app/uploads
|
||||
```
|
||||
|
||||
### Database Connection
|
||||
```bash
|
||||
# MySQL Health Check
|
||||
docker-compose -f docker-compose.modern.yml exec mysql mysqladmin ping
|
||||
|
||||
# Database Reset (⚠️ VORSICHT - löscht alle Daten)
|
||||
docker-compose -f docker-compose.modern.yml down -v
|
||||
```
|
||||
|
||||
## Backup & Restore
|
||||
|
||||
### Database Backup
|
||||
```bash
|
||||
docker-compose -f docker-compose.modern.yml exec mysql mysqldump -u recipes_user -p rezepte_klaus > backup.sql
|
||||
```
|
||||
|
||||
### Upload Backup
|
||||
```bash
|
||||
tar -czf uploads-backup.tar.gz docker-data/uploads/
|
||||
```
|
||||
|
||||
### Restore
|
||||
```bash
|
||||
# Database
|
||||
docker-compose -f docker-compose.modern.yml exec -T mysql mysql -u recipes_user -p rezepte_klaus < backup.sql
|
||||
|
||||
# Uploads
|
||||
tar -xzf uploads-backup.tar.gz
|
||||
```
|
||||
Reference in New Issue
Block a user