227 lines
4.2 KiB
Markdown
227 lines
4.2 KiB
Markdown
# 🚀 SeCu Deployment Guide
|
||
|
||
## Voraussetzungen
|
||
|
||
**Server:**
|
||
- Debian/Ubuntu Server (empfohlen: Debian 12)
|
||
- Min. 2GB RAM, 20GB Disk
|
||
- Root-Zugang
|
||
|
||
**Domains:**
|
||
- `secu.deine-domain.de` → Frontend
|
||
- `api.secu.deine-domain.de` → Backend
|
||
|
||
Beide Domains müssen auf die Server-IP zeigen (A-Record im DNS).
|
||
|
||
---
|
||
|
||
## Schnell-Installation (1 Befehl)
|
||
|
||
```bash
|
||
curl -sSL https://git.kronos-soulution.de/Flux_bot/secu/raw/branch/main/deploy/install.sh | bash
|
||
```
|
||
|
||
---
|
||
|
||
## Manuelle Installation
|
||
|
||
### 1️⃣ System vorbereiten
|
||
|
||
```bash
|
||
# Als root auf dem Server
|
||
apt update && apt upgrade -y
|
||
apt install -y git curl nginx certbot python3-certbot-nginx docker.io docker-compose
|
||
systemctl enable --now docker
|
||
```
|
||
|
||
### 2️⃣ Repo klonen
|
||
|
||
```bash
|
||
mkdir -p /srv/secu
|
||
cd /srv/secu
|
||
|
||
# Repos klonen
|
||
git clone https://git.kronos-soulution.de/Flux_bot/secu.git
|
||
git clone https://git.kronos-soulution.de/Flux_bot/secu-backend.git
|
||
git clone https://git.kronos-soulution.de/Flux_bot/secu-frontend.git
|
||
```
|
||
|
||
### 3️⃣ Umgebungsvariablen setzen
|
||
|
||
```bash
|
||
cd /srv/secu
|
||
|
||
# .env erstellen
|
||
cat > .env << 'EOF'
|
||
# Datenbank (kann so bleiben für lokale DB)
|
||
POSTGRES_USER=secu
|
||
POSTGRES_PASSWORD=SeCu2026!SecureDB
|
||
POSTGRES_DB=secu
|
||
|
||
# JWT Secret (ÄNDERN!)
|
||
JWT_SECRET=DEIN-GEHEIMER-SCHLUESSEL-HIER-AENDERN
|
||
|
||
# Deine Domain
|
||
DOMAIN=secu.deine-domain.de
|
||
API_DOMAIN=api.secu.deine-domain.de
|
||
EOF
|
||
```
|
||
|
||
⚠️ **Wichtig:** `JWT_SECRET` unbedingt ändern! Zufällig generieren:
|
||
```bash
|
||
openssl rand -base64 32
|
||
```
|
||
|
||
### 4️⃣ Nginx konfigurieren
|
||
|
||
```bash
|
||
# Domains anpassen
|
||
nano /srv/secu/secu/deploy/nginx/secu.conf
|
||
|
||
# Ersetze alle "secu.kronos-soulution.de" mit deiner Domain
|
||
# Ersetze alle "api.secu.kronos-soulution.de" mit deiner API-Domain
|
||
|
||
# Config kopieren
|
||
cp /srv/secu/secu/deploy/nginx/secu.conf /etc/nginx/sites-available/secu
|
||
ln -s /etc/nginx/sites-available/secu /etc/nginx/sites-enabled/
|
||
```
|
||
|
||
### 5️⃣ SSL-Zertifikate
|
||
|
||
```bash
|
||
# Zertifikate holen (Nginx muss laufen, Domains müssen erreichbar sein)
|
||
certbot --nginx -d secu.deine-domain.de -d api.secu.deine-domain.de
|
||
```
|
||
|
||
### 6️⃣ Docker starten
|
||
|
||
```bash
|
||
cd /srv/secu/secu/deploy
|
||
|
||
# Frontend API-URL anpassen
|
||
export VITE_API_URL=https://api.secu.deine-domain.de/api
|
||
|
||
# Container starten
|
||
docker-compose up -d
|
||
```
|
||
|
||
### 7️⃣ Prüfen
|
||
|
||
```bash
|
||
# Logs anschauen
|
||
docker-compose logs -f
|
||
|
||
# Health-Check
|
||
curl http://localhost:8004/health
|
||
curl http://localhost:3006
|
||
```
|
||
|
||
---
|
||
|
||
## 🔧 Konfiguration anpassen
|
||
|
||
### Eigene Domain verwenden
|
||
|
||
1. DNS A-Records setzen für beide Domains
|
||
2. In `/srv/secu/secu/deploy/nginx/secu.conf`:
|
||
- Alle `secu.kronos-soulution.de` ersetzen
|
||
3. In `/srv/secu/secu/deploy/docker-compose.yml`:
|
||
- `VITE_API_URL` anpassen
|
||
4. Nginx neu laden: `systemctl reload nginx`
|
||
|
||
### Datenbank-Passwort ändern
|
||
|
||
In `/srv/secu/secu/deploy/docker-compose.yml`:
|
||
```yaml
|
||
POSTGRES_PASSWORD: DeinNeuesPasswort
|
||
DATABASE_URL: postgres://secu:DeinNeuesPasswort@secu-db:5432/secu
|
||
```
|
||
|
||
Dann: `docker-compose down && docker-compose up -d`
|
||
|
||
---
|
||
|
||
## 📋 Wichtige Befehle
|
||
|
||
```bash
|
||
cd /srv/secu/secu/deploy
|
||
|
||
# Status prüfen
|
||
docker-compose ps
|
||
|
||
# Logs anzeigen
|
||
docker-compose logs -f
|
||
docker-compose logs -f secu-backend # nur Backend
|
||
|
||
# Neustart
|
||
docker-compose restart
|
||
|
||
# Komplett neu starten
|
||
docker-compose down && docker-compose up -d
|
||
|
||
# Updates holen
|
||
cd /srv/secu/secu && git pull
|
||
cd /srv/secu/secu-backend && git pull
|
||
cd /srv/secu/secu-frontend && git pull
|
||
docker-compose down && docker-compose up -d --build
|
||
```
|
||
|
||
---
|
||
|
||
## 🔒 Ports (Firewall)
|
||
|
||
Nur diese Ports müssen offen sein:
|
||
- **80** (HTTP → Redirect zu HTTPS)
|
||
- **443** (HTTPS)
|
||
|
||
Interne Ports (NICHT öffnen):
|
||
- 3006 (Frontend intern)
|
||
- 8004 (Backend intern)
|
||
- 5434 (PostgreSQL intern)
|
||
|
||
```bash
|
||
# UFW Firewall
|
||
ufw allow 80
|
||
ufw allow 443
|
||
ufw allow 22 # SSH nicht vergessen!
|
||
ufw enable
|
||
```
|
||
|
||
---
|
||
|
||
## ❓ Troubleshooting
|
||
|
||
### Container startet nicht
|
||
```bash
|
||
docker-compose logs secu-backend
|
||
docker-compose logs secu-db
|
||
```
|
||
|
||
### Datenbank-Verbindung fehlgeschlagen
|
||
```bash
|
||
docker exec -it secu-db psql -U secu -d secu
|
||
# Sollte PostgreSQL-Prompt zeigen
|
||
```
|
||
|
||
### SSL-Fehler
|
||
```bash
|
||
certbot renew --dry-run
|
||
nginx -t
|
||
```
|
||
|
||
### Alles zurücksetzen
|
||
```bash
|
||
docker-compose down -v # -v löscht auch die Datenbank!
|
||
docker-compose up -d
|
||
```
|
||
|
||
---
|
||
|
||
## 📞 Support
|
||
|
||
Bei Fragen: admin@kronos-soulution.de
|
||
|
||
---
|
||
|
||
*Stand: März 2026*
|