419 lines
8.3 KiB
Markdown
419 lines
8.3 KiB
Markdown
# Docker Deployment Anleitung für Windows Server / IIS
|
|
|
|
Diese Anleitung zeigt dir, wie du das FIDO-Key Management System mit Docker auf einem Windows Server bereitstellst.
|
|
|
|
---
|
|
|
|
## 📋 Voraussetzungen
|
|
|
|
### Auf dem Windows Server:
|
|
|
|
1. **Docker Desktop für Windows** oder **Docker Engine**
|
|
- Download: https://www.docker.com/products/docker-desktop
|
|
- Alternativ: Docker Engine über WSL2
|
|
|
|
2. **Port-Freigaben**:
|
|
- Port `80` für Frontend (oder ein anderer Port deiner Wahl)
|
|
- Port `5000` für Backend
|
|
|
|
---
|
|
|
|
## 🚀 Schnellstart (Lokaler Test)
|
|
|
|
### 1. Projekt vorbereiten
|
|
|
|
Öffne PowerShell im Projektordner:
|
|
|
|
```powershell
|
|
cd "C:\Users\gruessing\OneDrive - Cereda Systems GmbH\Desktop\IT Tool"
|
|
```
|
|
|
|
### 2. Docker Container bauen und starten
|
|
|
|
```powershell
|
|
docker-compose up -d --build
|
|
```
|
|
|
|
**Was passiert:**
|
|
- Backend und Frontend werden gebaut
|
|
- Container werden gestartet
|
|
- Datenbank wird automatisch initialisiert
|
|
|
|
### 3. Anwendung öffnen
|
|
|
|
Öffne im Browser: **http://localhost**
|
|
|
|
**Standard-Login:**
|
|
- Benutzername: `superadmin`
|
|
- Passwort: `Admin123!`
|
|
|
|
### 4. Container verwalten
|
|
|
|
**Status prüfen:**
|
|
```powershell
|
|
docker-compose ps
|
|
```
|
|
|
|
**Logs anzeigen:**
|
|
```powershell
|
|
docker-compose logs -f
|
|
```
|
|
|
|
**Container stoppen:**
|
|
```powershell
|
|
docker-compose down
|
|
```
|
|
|
|
**Container neustarten:**
|
|
```powershell
|
|
docker-compose restart
|
|
```
|
|
|
|
---
|
|
|
|
## 🌐 Deployment auf Windows Server mit IIS
|
|
|
|
### Option 1: Docker + IIS Reverse Proxy (EMPFOHLEN)
|
|
|
|
IIS kann als Reverse Proxy vor Docker verwendet werden.
|
|
|
|
#### Schritt 1: Docker auf Windows Server installieren
|
|
|
|
1. Docker Desktop für Windows installieren
|
|
2. Sicherstellen, dass Docker läuft: `docker --version`
|
|
|
|
#### Schritt 2: Projekt auf Server kopieren
|
|
|
|
Kopiere den kompletten `IT Tool` Ordner auf den Server, z.B.:
|
|
```
|
|
C:\inetpub\fido-key-manager\
|
|
```
|
|
|
|
#### Schritt 3: Container starten
|
|
|
|
```powershell
|
|
cd C:\inetpub\fido-key-manager
|
|
docker-compose up -d --build
|
|
```
|
|
|
|
#### Schritt 4: IIS als Reverse Proxy konfigurieren
|
|
|
|
**IIS URL Rewrite installieren:**
|
|
1. Download: https://www.iis.net/downloads/microsoft/url-rewrite
|
|
2. Installieren
|
|
|
|
**IIS Application Request Routing (ARR) installieren:**
|
|
1. Download: https://www.iis.net/downloads/microsoft/application-request-routing
|
|
2. Installieren
|
|
3. ARR aktivieren: IIS Manager → Server → Application Request Routing → Server Proxy Settings → "Enable proxy" aktivieren
|
|
|
|
**Neue Website in IIS erstellen:**
|
|
|
|
1. IIS Manager öffnen
|
|
2. Rechtsklick auf "Sites" → "Add Website"
|
|
3. Einstellungen:
|
|
- Site name: `FIDO-Key-Manager`
|
|
- Physical path: `C:\inetpub\wwwroot\fido` (leerer Ordner)
|
|
- Binding: HTTP, Port 80 (oder 443 für HTTPS)
|
|
- Host name: `your-domain.com`
|
|
|
|
4. `web.config` in `C:\inetpub\wwwroot\fido\` erstellen:
|
|
|
|
```xml
|
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
<configuration>
|
|
<system.webServer>
|
|
<rewrite>
|
|
<rules>
|
|
<!-- Backend API Requests -->
|
|
<rule name="Backend API" stopProcessing="true">
|
|
<match url="^api/(.*)" />
|
|
<action type="Rewrite" url="http://localhost:5000/api/{R:1}" />
|
|
</rule>
|
|
|
|
<!-- Frontend Requests -->
|
|
<rule name="Frontend" stopProcessing="true">
|
|
<match url="(.*)" />
|
|
<action type="Rewrite" url="http://localhost:80/{R:1}" />
|
|
</rule>
|
|
</rules>
|
|
</rewrite>
|
|
</system.webServer>
|
|
</configuration>
|
|
```
|
|
|
|
---
|
|
|
|
### Option 2: Docker ohne IIS (Direkter Zugriff)
|
|
|
|
Docker kann auch direkt ohne IIS laufen.
|
|
|
|
#### Ports in docker-compose.yml anpassen
|
|
|
|
Wenn Port 80 bereits von IIS belegt ist, ändere die Ports:
|
|
|
|
```yaml
|
|
services:
|
|
frontend:
|
|
ports:
|
|
- "8080:80" # Frontend auf Port 8080
|
|
|
|
backend:
|
|
ports:
|
|
- "5000:5000" # Backend auf Port 5000
|
|
```
|
|
|
|
Dann: **http://server-ip:8080**
|
|
|
|
---
|
|
|
|
## ⚙️ Konfiguration
|
|
|
|
### JWT Secret ändern (WICHTIG für Produktion!)
|
|
|
|
Bearbeite `docker-compose.yml`:
|
|
|
|
```yaml
|
|
environment:
|
|
- JWT_SECRET=IHR-SICHERES-ZUFÄLLIGES-SECRET-MINDESTENS-32-ZEICHEN
|
|
```
|
|
|
|
**Sicheres Secret generieren:**
|
|
|
|
```powershell
|
|
# PowerShell
|
|
-join ((65..90) + (97..122) + (48..57) + (33,35,36,37,38,42,43,45,61,63,64) | Get-Random -Count 32 | % {[char]$_})
|
|
```
|
|
|
|
### Frontend URL anpassen
|
|
|
|
In `docker-compose.yml`:
|
|
|
|
```yaml
|
|
environment:
|
|
- FRONTEND_URL=http://ihre-domain.com
|
|
```
|
|
|
|
---
|
|
|
|
## 💾 Datenbank & Backups
|
|
|
|
### Datenbank-Speicherort
|
|
|
|
Die Datenbank wird im Docker Volume `fido-data` gespeichert und bleibt auch nach Container-Neustarts erhalten.
|
|
|
|
### Backup erstellen
|
|
|
|
```powershell
|
|
# Container-ID finden
|
|
docker ps
|
|
|
|
# Backup erstellen
|
|
docker cp fido-backend:/app/data/database.sqlite C:\Backups\database-backup-$(Get-Date -Format "yyyy-MM-dd").sqlite
|
|
```
|
|
|
|
### Backup wiederherstellen
|
|
|
|
```powershell
|
|
# Container stoppen
|
|
docker-compose down
|
|
|
|
# Volume löschen
|
|
docker volume rm it-tool_fido-data
|
|
|
|
# Container neu starten
|
|
docker-compose up -d
|
|
|
|
# Backup einspielen
|
|
docker cp C:\Backups\database-backup.sqlite fido-backend:/app/data/database.sqlite
|
|
|
|
# Container neustarten
|
|
docker-compose restart backend
|
|
```
|
|
|
|
---
|
|
|
|
## 🔒 HTTPS / SSL einrichten
|
|
|
|
### Variante A: SSL Zertifikat über IIS (wenn IIS als Reverse Proxy verwendet wird)
|
|
|
|
1. Zertifikat in IIS importieren
|
|
2. HTTPS Binding hinzufügen
|
|
3. Fertig - IIS übernimmt SSL-Terminierung
|
|
|
|
### Variante B: SSL direkt in Docker (mit nginx)
|
|
|
|
Erstelle `nginx-ssl.conf` im Frontend-Ordner:
|
|
|
|
```nginx
|
|
server {
|
|
listen 443 ssl;
|
|
server_name ihre-domain.com;
|
|
|
|
ssl_certificate /etc/nginx/ssl/cert.pem;
|
|
ssl_certificate_key /etc/nginx/ssl/key.pem;
|
|
|
|
root /usr/share/nginx/html;
|
|
index index.html;
|
|
|
|
location / {
|
|
try_files $uri $uri/ /index.html;
|
|
}
|
|
}
|
|
```
|
|
|
|
Passe `docker-compose.yml` an:
|
|
|
|
```yaml
|
|
frontend:
|
|
ports:
|
|
- "443:443"
|
|
volumes:
|
|
- ./ssl-certs:/etc/nginx/ssl:ro
|
|
```
|
|
|
|
---
|
|
|
|
## 🔧 Troubleshooting
|
|
|
|
### Container starten nicht
|
|
|
|
```powershell
|
|
# Logs prüfen
|
|
docker-compose logs
|
|
|
|
# Spezifischen Container prüfen
|
|
docker-compose logs backend
|
|
docker-compose logs frontend
|
|
```
|
|
|
|
### Port bereits belegt
|
|
|
|
```powershell
|
|
# Prüfen, welcher Prozess Port 80 verwendet
|
|
netstat -ano | findstr :80
|
|
|
|
# Prozess beenden (Vorsicht!)
|
|
taskkill /PID <PID> /F
|
|
```
|
|
|
|
### Datenbank-Fehler
|
|
|
|
```powershell
|
|
# Container komplett neu aufsetzen
|
|
docker-compose down -v
|
|
docker-compose up -d --build
|
|
```
|
|
|
|
### Container läuft, aber nicht erreichbar
|
|
|
|
```powershell
|
|
# Windows Firewall prüfen
|
|
New-NetFirewallRule -DisplayName "Docker Frontend" -Direction Inbound -Protocol TCP -LocalPort 80 -Action Allow
|
|
New-NetFirewallRule -DisplayName "Docker Backend" -Direction Inbound -Protocol TCP -LocalPort 5000 -Action Allow
|
|
```
|
|
|
|
---
|
|
|
|
## 📊 Monitoring
|
|
|
|
### Container-Status überwachen
|
|
|
|
```powershell
|
|
# Status aller Container
|
|
docker-compose ps
|
|
|
|
# Ressourcennutzung
|
|
docker stats
|
|
```
|
|
|
|
### Logs in Echtzeit
|
|
|
|
```powershell
|
|
docker-compose logs -f --tail=100
|
|
```
|
|
|
|
---
|
|
|
|
## 🔄 Updates durchführen
|
|
|
|
Wenn du Änderungen am Code vornimmst:
|
|
|
|
```powershell
|
|
# Container stoppen
|
|
docker-compose down
|
|
|
|
# Neu bauen und starten
|
|
docker-compose up -d --build
|
|
|
|
# Alte Images aufräumen
|
|
docker image prune -f
|
|
```
|
|
|
|
---
|
|
|
|
## 📝 Wichtige Befehle im Überblick
|
|
|
|
```powershell
|
|
# Starten
|
|
docker-compose up -d
|
|
|
|
# Stoppen
|
|
docker-compose down
|
|
|
|
# Neu bauen
|
|
docker-compose up -d --build
|
|
|
|
# Logs anzeigen
|
|
docker-compose logs -f
|
|
|
|
# Status prüfen
|
|
docker-compose ps
|
|
|
|
# Container neustarten
|
|
docker-compose restart
|
|
|
|
# In Container einsteigen (Debugging)
|
|
docker exec -it fido-backend sh
|
|
docker exec -it fido-frontend sh
|
|
|
|
# Alle Container und Volumes löschen (VORSICHT - Datenverlust!)
|
|
docker-compose down -v
|
|
```
|
|
|
|
---
|
|
|
|
## 🎯 Production Checklist
|
|
|
|
Vor dem produktiven Einsatz:
|
|
|
|
- [ ] JWT_SECRET in `docker-compose.yml` geändert
|
|
- [ ] FRONTEND_URL angepasst
|
|
- [ ] HTTPS/SSL eingerichtet
|
|
- [ ] Firewall-Regeln konfiguriert
|
|
- [ ] Backup-Strategie implementiert
|
|
- [ ] Standard-Passwort des Super Admins geändert
|
|
- [ ] Windows Server Updates installiert
|
|
- [ ] Docker Desktop so konfiguriert, dass es automatisch startet
|
|
|
|
---
|
|
|
|
## 📞 Support
|
|
|
|
Bei Problemen:
|
|
1. Logs prüfen: `docker-compose logs`
|
|
2. Container-Status prüfen: `docker-compose ps`
|
|
3. Docker-Version prüfen: `docker --version`
|
|
4. Docker neu starten
|
|
|
|
---
|
|
|
|
## 🎉 Fertig!
|
|
|
|
Deine Anwendung läuft jetzt in Docker-Containern und kann einfach auf jedem Server bereitgestellt werden!
|
|
|
|
**Zugriff:**
|
|
- Frontend: http://localhost oder http://server-ip
|
|
- Backend API: http://localhost:5000 oder http://server-ip:5000
|
|
- Health Check: http://localhost:5000/health
|