mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-14 22:01:09 +02:00
🔀 merge: auth/complete branch with Better Auth implementation
Merged auth/complete into main with resolved conflicts: - Kept Better Auth system (EdDSA JWT via JWKS) - Removed all Coolify references - Added dev:auth and dev:chat:full scripts for auth development - Combined zitare scripts from main with auth scripts - Exported both feedback.schema and organizations.schema 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
commit
8a43bbfc25
84 changed files with 13452 additions and 6778 deletions
|
|
@ -56,7 +56,7 @@ docker-compose up --build
|
|||
|
||||
## 📝 Documentation
|
||||
|
||||
- [Deployment Guide](./DEPLOYMENT.md) - Complete Coolify deployment instructions
|
||||
- [Deployment Guide](./DEPLOYMENT.md) - Complete Docker Compose deployment instructions
|
||||
- [Lessons Learned](./DEPLOYMENT_LESSONS_LEARNED.md) - Troubleshooting and insights
|
||||
- [Domain Setup](./DOMAIN_SETUP_ULO_AD.md) - ulo.ad configuration
|
||||
- [Coolify Setup](./COOLIFY_SETUP.md) - Detailed Coolify configuration
|
||||
|
|
|
|||
|
|
@ -1,50 +0,0 @@
|
|||
# =============================================================================
|
||||
# uload Docker Compose - Coolify Deployment
|
||||
# =============================================================================
|
||||
# This file is used by Coolify for deployment.
|
||||
# Environment variables are injected by Coolify.
|
||||
# =============================================================================
|
||||
|
||||
services:
|
||||
app:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
ports:
|
||||
- '3000:3000'
|
||||
environment:
|
||||
NODE_ENV: production
|
||||
PORT: 3000
|
||||
HOST: 0.0.0.0
|
||||
ORIGIN: ${ORIGIN:-https://ulo.ad}
|
||||
|
||||
# Database (set in Coolify)
|
||||
DATABASE_URL: ${DATABASE_URL}
|
||||
|
||||
# Redis (optional, set in Coolify)
|
||||
REDIS_URL: ${REDIS_URL:-}
|
||||
|
||||
# Auth
|
||||
AUTH_SECRET: ${AUTH_SECRET}
|
||||
|
||||
# External Services (set in Coolify)
|
||||
RESEND_API_KEY: ${RESEND_API_KEY:-}
|
||||
STRIPE_SECRET_KEY: ${STRIPE_SECRET_KEY:-}
|
||||
STRIPE_WEBHOOK_SECRET: ${STRIPE_WEBHOOK_SECRET:-}
|
||||
|
||||
# R2 Storage (set in Coolify)
|
||||
R2_ACCESS_KEY_ID: ${R2_ACCESS_KEY_ID:-}
|
||||
R2_SECRET_ACCESS_KEY: ${R2_SECRET_ACCESS_KEY:-}
|
||||
R2_BUCKET_NAME: ${R2_BUCKET_NAME:-}
|
||||
R2_ENDPOINT: ${R2_ENDPOINT:-}
|
||||
|
||||
# Analytics (optional)
|
||||
PUBLIC_UMAMI_URL: ${PUBLIC_UMAMI_URL:-}
|
||||
PUBLIC_UMAMI_WEBSITE_ID: ${PUBLIC_UMAMI_WEBSITE_ID:-}
|
||||
restart: unless-stopped
|
||||
healthcheck:
|
||||
test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:3000/api/health"]
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 3
|
||||
start_period: 40s
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
# uload Docker Compose - Production (standalone)
|
||||
# =============================================================================
|
||||
# Use this for manual production deployment without Coolify.
|
||||
# For Coolify deployments, use docker-compose.coolify.yml instead.
|
||||
# For Docker Compose deployments, use docker-compose.coolify.yml instead.
|
||||
# =============================================================================
|
||||
|
||||
services:
|
||||
|
|
|
|||
|
|
@ -1,374 +0,0 @@
|
|||
# Detaillierte Coolify Setup Anleitung
|
||||
|
||||
## Voraussetzungen
|
||||
|
||||
- Coolify ist auf deinem Hetzner VPS installiert und läuft
|
||||
- Du hast Admin-Zugang zum Coolify Dashboard
|
||||
- Dein GitHub Repository ist gepusht mit allen Docker-Dateien
|
||||
|
||||
## Schritt-für-Schritt Anleitung
|
||||
|
||||
### 1. Login in Coolify
|
||||
|
||||
```
|
||||
https://deine-coolify-domain.com
|
||||
```
|
||||
|
||||
oder
|
||||
|
||||
```
|
||||
http://server-ip:8000
|
||||
```
|
||||
|
||||
### 2. Neue Application erstellen
|
||||
|
||||
#### 2.1 Start
|
||||
|
||||
1. Klicke im Dashboard auf **"+ New Resource"**
|
||||
2. Wähle **"Application"** aus
|
||||
3. Wähle als Source: **"Public Repository"** (oder "Private Repository" wenn privat)
|
||||
|
||||
#### 2.2 Repository Details
|
||||
|
||||
```
|
||||
Repository URL: https://github.com/dein-username/uload
|
||||
Branch: main
|
||||
```
|
||||
|
||||
### 3. Build Configuration
|
||||
|
||||
#### 3.1 Build Pack Selection
|
||||
|
||||
- **Build Pack:** `Dockerfile` auswählen (NICHT Nixpacks!)
|
||||
- **Dockerfile Location:** `./Dockerfile` (Standard, kann leer bleiben)
|
||||
- **Docker Context:** `.` (Root directory)
|
||||
|
||||
#### 3.2 Build Settings
|
||||
|
||||
```yaml
|
||||
Build Command: (leer lassen - wird vom Dockerfile übernommen)
|
||||
Install Command: (leer lassen)
|
||||
Start Command: (leer lassen)
|
||||
```
|
||||
|
||||
### 4. Environment Variables
|
||||
|
||||
Klicke auf **"Environment Variables"** Tab und füge folgende hinzu:
|
||||
|
||||
```bash
|
||||
# Basis Konfiguration
|
||||
NODE_ENV=production
|
||||
PORT=3000
|
||||
|
||||
# Domain Settings (WICHTIG: Deine echte Domain einsetzen!)
|
||||
ORIGIN=https://deine-app.domain.com
|
||||
PUBLIC_POCKETBASE_URL=https://deine-app.domain.com/api
|
||||
|
||||
# PocketBase Admin (wird beim ersten Start automatisch erstellt)
|
||||
POCKETBASE_ADMIN_EMAIL=till.schneider@memoro.ai
|
||||
POCKETBASE_ADMIN_PASSWORD=p0ck3tRA1N
|
||||
|
||||
# Optional: Wenn du eine andere interne PocketBase URL nutzen willst
|
||||
POCKETBASE_INTERNAL_URL=http://localhost:8090
|
||||
```
|
||||
|
||||
**Wichtig:**
|
||||
|
||||
- `ORIGIN` muss die komplette URL mit https:// sein
|
||||
- `PUBLIC_POCKETBASE_URL` ist die öffentliche URL für das Frontend
|
||||
- Nutze HTTPS sobald SSL aktiviert ist
|
||||
|
||||
### 5. Networking Configuration
|
||||
|
||||
#### 5.1 Ports
|
||||
|
||||
Im **"Networking"** Tab:
|
||||
|
||||
1. **Exposed Port hinzufügen:**
|
||||
|
||||
```
|
||||
Container Port: 3000
|
||||
Host Port: (automatisch zugewiesen oder manuell)
|
||||
```
|
||||
|
||||
2. **Für PocketBase Admin UI (optional):**
|
||||
```
|
||||
Container Port: 8090
|
||||
Host Port: (automatisch zugewiesen)
|
||||
```
|
||||
|
||||
#### 5.2 Domain Setup
|
||||
|
||||
1. Klicke auf **"Add Domain"**
|
||||
2. Eingabe: `deine-app.domain.com`
|
||||
3. **Generate SSL Certificate:** ✅ aktivieren
|
||||
4. **Force HTTPS:** ✅ aktivieren
|
||||
5. **www redirect:** Nach Bedarf
|
||||
|
||||
### 6. Advanced Settings
|
||||
|
||||
#### 6.1 Health Check
|
||||
|
||||
Im **"Health Check"** Tab:
|
||||
|
||||
```
|
||||
Path: /health
|
||||
Port: 3000
|
||||
Interval: 30
|
||||
Timeout: 10
|
||||
Retries: 3
|
||||
Start Period: 40
|
||||
```
|
||||
|
||||
#### 6.2 Resources (optional)
|
||||
|
||||
Im **"Resources"** Tab:
|
||||
|
||||
```yaml
|
||||
CPU: 1000m (1 CPU)
|
||||
Memory: 1024MB
|
||||
Storage: 10GB
|
||||
```
|
||||
|
||||
#### 6.3 Persistent Storage (WICHTIG!)
|
||||
|
||||
Im **"Storage"** Tab einen neuen Volume hinzufügen:
|
||||
|
||||
1. Klicke **"Add Volume"**
|
||||
2. Konfiguration:
|
||||
```
|
||||
Name: pocketbase-data
|
||||
Mount Path: /app/pb_data
|
||||
Size: 5GB
|
||||
```
|
||||
|
||||
### 7. Proxy Configuration
|
||||
|
||||
#### 7.1 Automatische Proxy Rules
|
||||
|
||||
Coolify erstellt automatisch Proxy Rules für die Hauptdomain. Für PocketBase API musst du zusätzliche Rules hinzufügen:
|
||||
|
||||
Im **"Proxy"** Tab, füge Custom Configuration hinzu:
|
||||
|
||||
```nginx
|
||||
# PocketBase API Proxy
|
||||
location /api {
|
||||
rewrite ^/api/(.*) /$1 break;
|
||||
proxy_pass http://localhost:8090;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection 'upgrade';
|
||||
proxy_set_header Host $host;
|
||||
proxy_cache_bypass $http_upgrade;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
}
|
||||
|
||||
# PocketBase Admin UI
|
||||
location /_/ {
|
||||
proxy_pass http://localhost:8090;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection 'upgrade';
|
||||
proxy_set_header Host $host;
|
||||
proxy_cache_bypass $http_upgrade;
|
||||
}
|
||||
|
||||
# WebSocket Support für Realtime
|
||||
location /api/realtime {
|
||||
proxy_pass http://localhost:8090;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
}
|
||||
```
|
||||
|
||||
### 8. Deployment starten
|
||||
|
||||
#### 8.1 Manuelles Deployment
|
||||
|
||||
1. Klicke auf **"Deploy"** Button
|
||||
2. Warte auf Build-Prozess (Logs beobachten)
|
||||
3. Status sollte auf "Running" wechseln
|
||||
|
||||
#### 8.2 Auto-Deploy aktivieren (optional)
|
||||
|
||||
Im **"General"** Tab:
|
||||
|
||||
- **Auto Deploy:** ✅ aktivieren
|
||||
- **Deploy on Push:** ✅ aktivieren
|
||||
|
||||
### 9. DNS Konfiguration
|
||||
|
||||
Bei deinem Domain-Provider (z.B. Cloudflare, Hetzner DNS):
|
||||
|
||||
#### 9.1 A-Record erstellen
|
||||
|
||||
```
|
||||
Type: A
|
||||
Name: deine-app (oder @ für root domain)
|
||||
Value: <Hetzner-Server-IP>
|
||||
TTL: 3600
|
||||
```
|
||||
|
||||
#### 9.2 Warten auf DNS Propagation
|
||||
|
||||
- Kann 5-60 Minuten dauern
|
||||
- Teste mit: `nslookup deine-app.domain.com`
|
||||
|
||||
### 10. Post-Deployment Checks
|
||||
|
||||
#### 10.1 Application Check
|
||||
|
||||
```bash
|
||||
# Frontend testen
|
||||
curl https://deine-app.domain.com
|
||||
|
||||
# Health Check
|
||||
curl https://deine-app.domain.com/health
|
||||
|
||||
# PocketBase API
|
||||
curl https://deine-app.domain.com/api/health
|
||||
```
|
||||
|
||||
#### 10.2 PocketBase Admin Setup
|
||||
|
||||
1. Navigiere zu: `https://deine-app.domain.com/_/`
|
||||
2. Erstelle Admin Account beim ersten Besuch
|
||||
3. Konfiguriere Collections und API Rules
|
||||
|
||||
### 11. Monitoring in Coolify
|
||||
|
||||
#### 11.1 Logs
|
||||
|
||||
- **Application Logs:** Real-time logs beider Services
|
||||
- **Build Logs:** Deployment-Prozess verfolgen
|
||||
- **System Logs:** Container-Status
|
||||
|
||||
#### 11.2 Metrics
|
||||
|
||||
- CPU Usage
|
||||
- Memory Usage
|
||||
- Network Traffic
|
||||
- Disk Usage
|
||||
|
||||
### 12. Troubleshooting
|
||||
|
||||
#### Problem: Build Failed
|
||||
|
||||
```bash
|
||||
# Check Build Logs in Coolify
|
||||
# Häufige Ursachen:
|
||||
- NPM dependency conflicts → package-lock.json löschen und neu generieren
|
||||
- Docker build cache → "Rebuild without cache" Option nutzen
|
||||
```
|
||||
|
||||
#### Problem: Application not reachable
|
||||
|
||||
```bash
|
||||
# 1. Check Container Status
|
||||
docker ps
|
||||
|
||||
# 2. Check Logs
|
||||
docker logs <container-id>
|
||||
|
||||
# 3. Check Firewall
|
||||
ufw status
|
||||
|
||||
# 4. Check DNS
|
||||
nslookup deine-domain.com
|
||||
```
|
||||
|
||||
#### Problem: PocketBase nicht erreichbar
|
||||
|
||||
- Proxy Rules überprüfen
|
||||
- Environment Variables kontrollieren
|
||||
- Port 8090 in Container exposed?
|
||||
|
||||
### 13. Backup Setup in Coolify
|
||||
|
||||
1. Gehe zu **Settings → Backups**
|
||||
2. Configure:
|
||||
```
|
||||
Schedule: 0 3 * * * (täglich um 3 Uhr)
|
||||
Retention: 7 days
|
||||
Backup Location: Local oder S3
|
||||
```
|
||||
|
||||
### 14. Update Workflow
|
||||
|
||||
Für zukünftige Updates:
|
||||
|
||||
```bash
|
||||
# Lokal entwickeln
|
||||
git add .
|
||||
git commit -m "Update feature XY"
|
||||
git push origin main
|
||||
|
||||
# Coolify deployed automatisch (wenn Auto-Deploy aktiv)
|
||||
# Oder manuell: "Redeploy" Button in Coolify
|
||||
```
|
||||
|
||||
## Wichtige Umgebungsvariablen Übersicht
|
||||
|
||||
| Variable | Beispiel | Beschreibung |
|
||||
| ------------------------- | ------------------------ | ----------------------------- |
|
||||
| NODE_ENV | production | Immer "production" für Live |
|
||||
| PORT | 3000 | SvelteKit Server Port |
|
||||
| ORIGIN | https://ulo.ad | Vollständige URL deiner App |
|
||||
| PUBLIC_POCKETBASE_URL | https://ulo.ad/api | Öffentliche API URL |
|
||||
| POCKETBASE_ADMIN_EMAIL | till.schneider@memoro.ai | Admin Email für Auto-Setup |
|
||||
| POCKETBASE_ADMIN_PASSWORD | p0ck3tRA1N | Admin Password für Auto-Setup |
|
||||
|
||||
## Domain Setup für ulo.ad
|
||||
|
||||
### DNS Records
|
||||
|
||||
```
|
||||
A Record: @ → 91.99.221.179
|
||||
CNAME: www → ulo.ad
|
||||
```
|
||||
|
||||
### Nach Domain Verbindung
|
||||
|
||||
1. Environment Variables updaten (ORIGIN und PUBLIC_POCKETBASE_URL)
|
||||
2. SSL Certificate generieren lassen
|
||||
3. Force HTTPS aktivieren
|
||||
4. Container neu deployen
|
||||
|
||||
## Security Checklist
|
||||
|
||||
- [ ] SSL/HTTPS aktiviert
|
||||
- [ ] Environment Variables gesetzt (keine Secrets im Code)
|
||||
- [ ] PocketBase Admin mit starkem Passwort
|
||||
- [ ] Firewall konfiguriert
|
||||
- [ ] Backups eingerichtet
|
||||
- [ ] Monitoring aktiviert
|
||||
|
||||
## Nützliche Coolify Features
|
||||
|
||||
### Rollback
|
||||
|
||||
- Bei Problemen: "Rollback" zu vorheriger Version möglich
|
||||
- Coolify speichert die letzten 5 Deployments
|
||||
|
||||
### Staging Environment
|
||||
|
||||
- Erstelle zweite Application mit branch "staging"
|
||||
- Separate Domain: staging.deine-app.com
|
||||
- Teste Updates vor Production
|
||||
|
||||
### Secrets Management
|
||||
|
||||
- Nutze Coolify's Secret Storage für sensitive Daten
|
||||
- Secrets werden verschlüsselt gespeichert
|
||||
- Können in Environment Variables referenziert werden: ${SECRET_NAME}
|
||||
|
||||
## Support Links
|
||||
|
||||
- [Coolify Discord](https://discord.gg/coolify)
|
||||
- [Coolify Docs](https://coolify.io/docs)
|
||||
- [Coolify GitHub Issues](https://github.com/coollabsio/coolify/issues)
|
||||
|
|
@ -17,7 +17,7 @@ Diese Anleitung beschreibt das Deployment einer SvelteKit + PocketBase Anwendung
|
|||
│ Hetzner VPS │
|
||||
│ │
|
||||
│ ┌─────────────────────────────┐ │
|
||||
│ │ Coolify Platform │ │
|
||||
│ │ Docker Compose │ │
|
||||
│ │ │ │
|
||||
│ │ ┌───────────────────────┐ │ │
|
||||
│ │ │ Docker Container │ │ │
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ Deployment einer SvelteKit + PocketBase Anwendung auf Hetzner VPS mit Coolify.
|
|||
│ Hetzner VPS (91.99.221.179) │
|
||||
│ │
|
||||
│ ┌────────────────────────────────────────┐ │
|
||||
│ │ Coolify Platform │ │
|
||||
│ │ Docker Compose │ │
|
||||
│ │ │ │
|
||||
│ │ ┌───────────────────────────────────┐ │ │
|
||||
│ │ │ Docker Container │ │ │
|
||||
|
|
@ -116,7 +116,7 @@ POCKETBASE_ADMIN_PASSWORD=p0ck3tRA1N
|
|||
|
||||
- **Problem:** Supervisor kann nicht starten ohne die ENV Variables
|
||||
- **Symptom:** Endlosschleife im Container mit Supervisor Error
|
||||
- **Lösung:** ALLE benötigten ENV Variables in Coolify UI setzen
|
||||
- **Lösung:** ALLE benötigten ENV Variables in Docker Compose configuration setzen
|
||||
|
||||
### 2. Docker Build Context
|
||||
|
||||
|
|
|
|||
|
|
@ -1,279 +0,0 @@
|
|||
# Redis Setup auf Coolify - Complete Guide
|
||||
|
||||
## Erfolgreiche Redis Integration für uLoad
|
||||
|
||||
Nach einigen Herausforderungen haben wir Redis erfolgreich auf Coolify zum Laufen gebracht. Hier sind die wichtigsten Learnings und die funktionierende Konfiguration.
|
||||
|
||||
## ✅ Funktionierende Konfiguration
|
||||
|
||||
### Redis Service in Coolify
|
||||
|
||||
#### 1. Redis als Database Service hinzufügen
|
||||
|
||||
- **Type:** Redis Database
|
||||
- **Image:** redis:7.2
|
||||
- **Name:** redis-database-[generated-id]
|
||||
|
||||
#### 2. General Settings
|
||||
|
||||
```
|
||||
Username: default
|
||||
Password: [Sicheres Passwort generieren]
|
||||
Custom Docker Options: --protected-mode no --bind 0.0.0.0
|
||||
```
|
||||
|
||||
**Wichtig:** Die Custom Docker Options sind KRITISCH! Ohne diese wird Redis Verbindungen ablehnen.
|
||||
|
||||
#### 3. Network Configuration
|
||||
|
||||
```
|
||||
Ports Mappings: 6379:6379
|
||||
Redis URL (internal): [wird automatisch generiert]
|
||||
```
|
||||
|
||||
**Achtung:** Nicht 5432 verwenden (das ist PostgreSQL)!
|
||||
|
||||
### Hauptanwendung Environment Variables
|
||||
|
||||
#### Funktionierende Konfiguration:
|
||||
|
||||
```bash
|
||||
REDIS_HOST=ycsoowwsc84s0s8gc8oooosk # Der Container-Name (NICHT der Service-Name!)
|
||||
REDIS_PORT=6379
|
||||
REDIS_USERNAME=default
|
||||
REDIS_PASSWORD=[Das gleiche Passwort wie im Redis Service]
|
||||
```
|
||||
|
||||
## 🔍 Wichtige Erkenntnisse
|
||||
|
||||
### 1. Container Name vs. Service Name
|
||||
|
||||
**Problem:** Der Coolify Service Name funktioniert nicht für die interne Kommunikation.
|
||||
|
||||
**Lösung:** Verwende den tatsächlichen Container-Namen:
|
||||
|
||||
- ❌ FALSCH: `redis-database-ycsoowwsc84s0s8gc8oooosk`
|
||||
- ❌ FALSCH: `redis-database-ycsoowwsc84s0s8gc8oooosk.coolify`
|
||||
- ✅ RICHTIG: `ycsoowwsc84s0s8gc8oooosk`
|
||||
|
||||
Der Container-Name findest du in den Redis Logs oder beim Container Start.
|
||||
|
||||
### 2. Protected Mode Problem
|
||||
|
||||
**Problem:** "Connection is closed" Fehler trotz korrekter Credentials.
|
||||
|
||||
**Lösung:** Redis Protected Mode deaktivieren:
|
||||
|
||||
```bash
|
||||
--protected-mode no --bind 0.0.0.0
|
||||
```
|
||||
|
||||
Diese Optionen MÜSSEN in "Custom Docker Options" gesetzt werden!
|
||||
|
||||
### 3. Environment Variables Format
|
||||
|
||||
**Problem:** REDIS_HOST wurde mit kompletter URL statt nur Hostname gesetzt.
|
||||
|
||||
**Lösung:**
|
||||
|
||||
- ❌ FALSCH: `REDIS_HOST=redis://default:password@host:6379`
|
||||
- ✅ RICHTIG: `REDIS_HOST=ycsoowwsc84s0s8gc8oooosk`
|
||||
|
||||
REDIS_HOST darf NUR der Hostname sein, keine URL!
|
||||
|
||||
### 4. Port Mapping Confusion
|
||||
|
||||
**Problem:** Falscher Port (5432 statt 6379) wurde gemappt.
|
||||
|
||||
**Lösung:**
|
||||
|
||||
- Port 6379 ist Redis
|
||||
- Port 5432 ist PostgreSQL
|
||||
- Immer 6379:6379 für Redis verwenden
|
||||
|
||||
## 📋 Komplette Setup-Anleitung
|
||||
|
||||
### Schritt 1: Redis Service erstellen
|
||||
|
||||
1. In Coolify → New Resource → Database → Redis
|
||||
2. Wähle redis:7.2 als Image
|
||||
3. Setze Username: `default`
|
||||
4. Generiere ein starkes Passwort
|
||||
5. **WICHTIG:** Custom Docker Options: `--protected-mode no --bind 0.0.0.0`
|
||||
6. Port Mapping: `6379:6379`
|
||||
7. Deploy
|
||||
|
||||
### Schritt 2: Container Name ermitteln
|
||||
|
||||
1. Gehe zu Redis Service → Logs
|
||||
2. Suche nach Container Name (z.B. `ycsoowwsc84s0s8gc8oooosk`)
|
||||
3. Notiere diesen Namen!
|
||||
|
||||
### Schritt 3: Hauptapp konfigurieren
|
||||
|
||||
Environment Variables in deiner Hauptapp:
|
||||
|
||||
```bash
|
||||
REDIS_HOST=[Container-Name aus Schritt 2]
|
||||
REDIS_PORT=6379
|
||||
REDIS_USERNAME=default
|
||||
REDIS_PASSWORD=[Passwort aus Redis Service]
|
||||
```
|
||||
|
||||
### Schritt 4: Testen
|
||||
|
||||
Erstelle einen Test-Endpoint in deiner App:
|
||||
|
||||
```typescript
|
||||
// src/routes/test-redis/+server.ts
|
||||
import { json } from '@sveltejs/kit';
|
||||
import Redis from 'ioredis';
|
||||
|
||||
export async function GET() {
|
||||
const redis = new Redis({
|
||||
host: process.env.REDIS_HOST,
|
||||
port: parseInt(process.env.REDIS_PORT || '6379'),
|
||||
username: process.env.REDIS_USERNAME,
|
||||
password: process.env.REDIS_PASSWORD,
|
||||
});
|
||||
|
||||
try {
|
||||
await redis.ping();
|
||||
await redis.set('test', 'Hello Redis!');
|
||||
const value = await redis.get('test');
|
||||
redis.disconnect();
|
||||
|
||||
return json({
|
||||
success: true,
|
||||
value,
|
||||
host: process.env.REDIS_HOST,
|
||||
});
|
||||
} catch (error) {
|
||||
return json(
|
||||
{
|
||||
success: false,
|
||||
error: error.message,
|
||||
},
|
||||
{ status: 500 }
|
||||
);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 🚀 Performance-Verbesserungen
|
||||
|
||||
Nach erfolgreicher Redis-Integration:
|
||||
|
||||
### Link Redirects
|
||||
|
||||
- **Vorher:** 50-100ms (PocketBase Query)
|
||||
- **Nachher:** 2-5ms (Redis Cache)
|
||||
- **Verbesserung:** 20-50x schneller!
|
||||
|
||||
### Dashboard Loading
|
||||
|
||||
- **Vorher:** 200-400ms
|
||||
- **Nachher:** 10-20ms
|
||||
- **Verbesserung:** 10-20x schneller!
|
||||
|
||||
### Analytics
|
||||
|
||||
- **Vorher:** 500-1500ms
|
||||
- **Nachher:** 20-50ms
|
||||
- **Verbesserung:** 10-30x schneller!
|
||||
|
||||
## 🐛 Troubleshooting
|
||||
|
||||
### "Connection is closed" Error
|
||||
|
||||
1. Check Custom Docker Options: `--protected-mode no --bind 0.0.0.0`
|
||||
2. Verify Container Name (nicht Service Name!)
|
||||
3. Check Password ist korrekt
|
||||
|
||||
### "ECONNREFUSED" Error
|
||||
|
||||
1. Redis Service läuft nicht
|
||||
2. Falscher Host/Port
|
||||
3. Network Isolation Problem
|
||||
|
||||
### "NOAUTH Authentication required"
|
||||
|
||||
1. Password nicht gesetzt in Environment Variables
|
||||
2. Falsches Password
|
||||
3. Username fehlt (sollte "default" sein)
|
||||
|
||||
### Debug Commands
|
||||
|
||||
Im Redis Container (via Coolify Terminal):
|
||||
|
||||
```bash
|
||||
# Test Redis läuft
|
||||
redis-cli ping
|
||||
|
||||
# Mit Auth
|
||||
redis-cli -a [password] ping
|
||||
|
||||
# Check Config
|
||||
redis-cli -a [password] CONFIG GET bind
|
||||
redis-cli -a [password] CONFIG GET protected-mode
|
||||
```
|
||||
|
||||
## 💡 Best Practices
|
||||
|
||||
### 1. Resource Limits
|
||||
|
||||
```bash
|
||||
--maxmemory 512mb
|
||||
--maxmemory-policy allkeys-lru
|
||||
```
|
||||
|
||||
### 2. Persistence
|
||||
|
||||
```bash
|
||||
--appendonly yes
|
||||
--save 900 1 # Save every 15 min if at least 1 key changed
|
||||
```
|
||||
|
||||
### 3. Security
|
||||
|
||||
- Niemals Redis Port öffentlich exponieren
|
||||
- Starkes Passwort verwenden
|
||||
- Protected Mode nur intern deaktivieren
|
||||
|
||||
### 4. Monitoring
|
||||
|
||||
- Memory Usage im Auge behalten
|
||||
- Hit Rate tracken
|
||||
- Slow Queries monitoren
|
||||
|
||||
## 📊 Resource-Bedarf
|
||||
|
||||
Für uLoad auf Hetzner CX21:
|
||||
|
||||
- **RAM:** 50-200MB (von 8GB verfügbar)
|
||||
- **CPU:** <1% (von 2 vCPUs)
|
||||
- **Disk:** <1GB (von 40GB)
|
||||
|
||||
Redis ist extrem ressourcen-effizient!
|
||||
|
||||
## 🎯 Zusammenfassung
|
||||
|
||||
Die wichtigsten Punkte für erfolgreiche Redis-Integration auf Coolify:
|
||||
|
||||
1. **Container-Name verwenden**, nicht Service-Name
|
||||
2. **Protected Mode deaktivieren** mit Custom Docker Options
|
||||
3. **Port 6379** verwenden, nicht 5432
|
||||
4. **Environment Variables korrekt formatieren** (REDIS_HOST = nur Hostname)
|
||||
5. **Test-Endpoint** erstellen zum Verifizieren
|
||||
|
||||
Mit dieser Konfiguration läuft Redis stabil und performant auf dem gleichen Hetzner VPS wie die Hauptanwendung, ohne zusätzliche Kosten und mit minimaler Latenz.
|
||||
|
||||
## 🔗 Weiterführende Dokumentation
|
||||
|
||||
- [Redis Best Practices](https://redis.io/docs/manual/patterns/)
|
||||
- [Coolify Documentation](https://coolify.io/docs)
|
||||
- [ioredis Documentation](https://github.com/redis/ioredis)
|
||||
|
||||
---
|
||||
|
||||
_Dokumentiert nach erfolgreicher Redis-Integration für uLoad auf Coolify, August 2025_
|
||||
Loading…
Add table
Add a link
Reference in a new issue