added docker setup
This commit is contained in:
parent
57ae9c3320
commit
be5ce63add
12 changed files with 509 additions and 20 deletions
185
README-Docker.md
Normal file
185
README-Docker.md
Normal file
|
@ -0,0 +1,185 @@
|
|||
# Tschunk Order - Docker Deployment
|
||||
|
||||
Diese Anleitung beschreibt, wie Sie die Tschunk Order Anwendung mit Docker Compose deployen können.
|
||||
|
||||
## Voraussetzungen
|
||||
|
||||
- Docker
|
||||
- Docker Compose
|
||||
|
||||
## Projektstruktur
|
||||
|
||||
```
|
||||
tschunkorder/
|
||||
├── docker-compose.yml # Haupt-Konfiguration
|
||||
├── frontend/
|
||||
│ ├── Dockerfile # Frontend Container
|
||||
│ ├── nginx.conf # Frontend Nginx-Konfiguration
|
||||
│ └── .dockerignore
|
||||
├── backend/
|
||||
│ ├── Dockerfile # Backend Container
|
||||
│ └── .dockerignore
|
||||
└── nginx/
|
||||
├── nginx.conf # Haupt-Nginx-Konfiguration
|
||||
└── conf.d/
|
||||
└── default.conf # Reverse Proxy-Konfiguration
|
||||
```
|
||||
|
||||
## Services
|
||||
|
||||
### 1. Frontend (Vue.js + Vite)
|
||||
- **Port**: Intern 80, extern über Nginx
|
||||
- **Technologie**: Vue.js 3 mit Vite
|
||||
- **Container**: `tschunk-frontend`
|
||||
|
||||
### 2. Backend (FastAPI)
|
||||
- **Port**: Intern 8000, extern 8000 (optional)
|
||||
- **Technologie**: FastAPI mit Uvicorn
|
||||
- **Container**: `tschunk-backend`
|
||||
|
||||
### 3. Nginx Reverse Proxy
|
||||
- **Port**: 80 (HTTP), 443 (HTTPS, optional)
|
||||
- **Funktion**: Reverse Proxy für Frontend und Backend
|
||||
- **Container**: `tschunk-nginx`
|
||||
|
||||
## Deployment
|
||||
|
||||
### 1. Anwendung starten
|
||||
|
||||
```bash
|
||||
# Alle Services bauen und starten
|
||||
docker-compose up --build
|
||||
|
||||
# Im Hintergrund starten
|
||||
docker-compose up --build -d
|
||||
```
|
||||
|
||||
### 2. Anwendung stoppen
|
||||
|
||||
```bash
|
||||
# Services stoppen
|
||||
docker-compose down
|
||||
|
||||
# Services und Volumes löschen
|
||||
docker-compose down -v
|
||||
```
|
||||
|
||||
### 3. Logs anzeigen
|
||||
|
||||
```bash
|
||||
# Alle Logs
|
||||
docker-compose logs
|
||||
|
||||
# Spezifischer Service
|
||||
docker-compose logs frontend
|
||||
docker-compose logs backend
|
||||
docker-compose logs nginx
|
||||
|
||||
# Logs folgen
|
||||
docker-compose logs -f
|
||||
```
|
||||
|
||||
## Zugriff auf die Anwendung
|
||||
|
||||
- **Frontend**: http://localhost/ (oder IP-Adresse)
|
||||
- **Backend API**: http://localhost/api/ (oder IP-Adresse)
|
||||
- **WebSocket**: ws://localhost/api/ws (oder IP-Adresse)
|
||||
- **Health Check**: http://localhost/health (oder IP-Adresse)
|
||||
|
||||
## API-Endpunkte
|
||||
|
||||
- `GET /api/orders` - Alle Bestellungen abrufen
|
||||
- `POST /api/orders` - Neue Bestellung erstellen
|
||||
- `DELETE /api/orders/{id}` - Bestellung löschen
|
||||
- `GET /api/drinks` - Verfügbare Getränke
|
||||
|
||||
## WebSocket
|
||||
|
||||
Der WebSocket-Endpunkt ist unter `ws://localhost/api/ws` verfügbar und unterstützt:
|
||||
- Echtzeit-Updates bei neuen/gelöschten Bestellungen
|
||||
- Ping/Pong für Verbindungsüberwachung
|
||||
- Bestellungen erstellen/löschen über WebSocket
|
||||
|
||||
## Konfiguration
|
||||
|
||||
### Umgebungsvariablen
|
||||
|
||||
#### Frontend
|
||||
- `VITE_API_BASE_URL`: Backend API URL (Standard: http://backend:8000)
|
||||
|
||||
#### Backend
|
||||
- `PYTHONUNBUFFERED`: Python Output nicht puffern (Standard: 1)
|
||||
|
||||
### Nginx-Konfiguration
|
||||
|
||||
Die Nginx-Konfiguration befindet sich in:
|
||||
- `nginx/nginx.conf` - Haupt-Konfiguration
|
||||
- `nginx/conf.d/default.conf` - Server-Konfiguration
|
||||
|
||||
#### Features
|
||||
- Rate Limiting für API und WebSocket
|
||||
- Gzip-Kompression
|
||||
- Security Headers
|
||||
- WebSocket-Support
|
||||
- SPA-Routing für Frontend
|
||||
- Vereinfachte Proxy-Logik (alle API-Endpunkte unter /api)
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Container startet nicht
|
||||
```bash
|
||||
# Logs prüfen
|
||||
docker-compose logs [service-name]
|
||||
|
||||
# Container neu bauen
|
||||
docker-compose build --no-cache [service-name]
|
||||
```
|
||||
|
||||
### Netzwerk-Probleme
|
||||
```bash
|
||||
# Netzwerk-Status prüfen
|
||||
docker network ls
|
||||
docker network inspect tschunkorder_tschunk-network
|
||||
```
|
||||
|
||||
### Port-Konflikte
|
||||
Falls Port 80 bereits belegt ist, ändern Sie in `docker-compose.yml`:
|
||||
```yaml
|
||||
nginx:
|
||||
ports:
|
||||
- "8080:80" # Statt "80:80"
|
||||
```
|
||||
|
||||
## Entwicklung
|
||||
|
||||
### Hot Reload (Entwicklung)
|
||||
Für die Entwicklung können Sie die Services einzeln starten:
|
||||
|
||||
```bash
|
||||
# Backend mit Hot Reload
|
||||
cd backend
|
||||
uvicorn main:app --reload --host 0.0.0.0 --port 8000
|
||||
|
||||
# Frontend mit Hot Reload
|
||||
cd frontend
|
||||
npm run dev
|
||||
```
|
||||
|
||||
### Datenbank-Persistenz
|
||||
Die aktuelle Implementierung verwendet eine In-Memory-Datenbank. Für Produktionsumgebungen sollten Sie eine persistente Datenbank hinzufügen.
|
||||
|
||||
## Sicherheit
|
||||
|
||||
- Alle Services laufen in isolierten Containern
|
||||
- Nginx bietet Rate Limiting und Security Headers
|
||||
- Backend läuft als non-root User
|
||||
- WebSocket-Verbindungen sind begrenzt
|
||||
|
||||
## Monitoring
|
||||
|
||||
### Health Checks
|
||||
- Backend: Automatischer Health Check alle 30 Sekunden
|
||||
- Nginx: `/health` Endpunkt
|
||||
|
||||
### Logs
|
||||
Alle Services loggen in stdout/stderr und können über `docker-compose logs` abgerufen werden.
|
Loading…
Add table
Add a link
Reference in a new issue