Initial: Docker-Compose-Stack für Rapport Self-Hosting

Komplettes Bundle für eigene Rapport-Instanz:
- Postgres mit Supabase-Extensions + Init-Script für Standard-Rollen
- GoTrue (Auth) mit konfigurierbarem SMTP für Passwort-Reset-Mails
- PostgREST (REST-API)
- Realtime (Postgres-Changes für Live-Sync)
- Storage-API (Bilder/Quittungen)
- Kong als API-Gateway
- Rapport-Frontend als Multi-Stage-Build (zieht Sources aus dem App-Repo)

Plus:
- scripts/sync-migrations.sh: holt SQL aus dem App-Repo
- .env.example mit allen Pflicht-Secrets + optionalen SMTP-Werten
- nginx.conf mit SPA-Routing
- README mit Setup-Anleitung (Linux + macOS-Colima)
- LICENSE (AGPL-3.0)

Sync mit App-Repo: scripts/sync-migrations.sh holt die Migrations-SQL via
git clone und legt sie nach volumes/db/init/migrations/. Bei jedem
Rapport-Update erneut ausführen.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-05-23 20:10:54 +02:00
commit 945e46fb03
10 changed files with 589 additions and 0 deletions
+185
View File
@@ -0,0 +1,185 @@
# Rapport-Server — Komplettstack für Self-Hosting.
#
# Bevor `docker compose up`:
# 1. cp .env.example .env und Secrets ersetzen
# 2. ./scripts/sync-migrations.sh (holt SQL aus dem App-Repo)
#
# Dann:
# docker compose up -d
#
# Erststart dauert ~1 Min (Postgres bootet, Migrations laufen, Health-Checks).
services:
# ════════════════════════════════════════════════════════════════════════
# Postgres — Datenbank mit Supabase-Extensions
# ════════════════════════════════════════════════════════════════════════
db:
image: supabase/postgres:15.8.1.020
container_name: rapport-db
restart: unless-stopped
environment:
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
POSTGRES_DB: postgres
JWT_SECRET: ${JWT_SECRET}
JWT_EXP: 3600
volumes:
- postgres-data:/var/lib/postgresql/data
- ./volumes/db/init/migrations:/docker-entrypoint-initdb.d/migrations:ro
- ./volumes/db/init/00-init.sh:/docker-entrypoint-initdb.d/00-init.sh:ro
ports:
- "${DB_PORT:-5432}:5432"
healthcheck:
test: ["CMD", "pg_isready", "-U", "postgres"]
interval: 5s
timeout: 5s
retries: 10
# ════════════════════════════════════════════════════════════════════════
# GoTrue — Auth (Email-Login, Passwort-Reset, Magic-Links)
# ════════════════════════════════════════════════════════════════════════
auth:
image: supabase/gotrue:v2.158.1
container_name: rapport-auth
restart: unless-stopped
depends_on:
db:
condition: service_healthy
environment:
GOTRUE_API_HOST: 0.0.0.0
GOTRUE_API_PORT: 9999
API_EXTERNAL_URL: ${API_EXTERNAL_URL}
GOTRUE_DB_DRIVER: postgres
GOTRUE_DB_DATABASE_URL: postgres://supabase_auth_admin:${POSTGRES_PASSWORD}@db:5432/postgres
GOTRUE_SITE_URL: ${SITE_URL}
GOTRUE_URI_ALLOW_LIST: ${SITE_URL},${SITE_URL}/
GOTRUE_DISABLE_SIGNUP: "false"
GOTRUE_JWT_ADMIN_ROLES: service_role
GOTRUE_JWT_AUD: authenticated
GOTRUE_JWT_DEFAULT_GROUP_NAME: authenticated
GOTRUE_JWT_EXP: 3600
GOTRUE_JWT_SECRET: ${JWT_SECRET}
GOTRUE_EXTERNAL_EMAIL_ENABLED: "true"
GOTRUE_MAILER_AUTOCONFIRM: "true"
GOTRUE_SMTP_HOST: ${SMTP_HOST:-}
GOTRUE_SMTP_PORT: ${SMTP_PORT:-587}
GOTRUE_SMTP_USER: ${SMTP_USER:-}
GOTRUE_SMTP_PASS: ${SMTP_PASS:-}
GOTRUE_SMTP_ADMIN_EMAIL: ${SMTP_ADMIN_EMAIL:-admin@rapport.local}
GOTRUE_SMTP_SENDER_NAME: ${SMTP_SENDER_NAME:-Rapport}
# ════════════════════════════════════════════════════════════════════════
# PostgREST — REST-API auf der Datenbank
# ════════════════════════════════════════════════════════════════════════
rest:
image: postgrest/postgrest:v12.2.0
container_name: rapport-rest
restart: unless-stopped
depends_on:
db:
condition: service_healthy
environment:
PGRST_DB_URI: postgres://authenticator:${POSTGRES_PASSWORD}@db:5432/postgres
PGRST_DB_SCHEMAS: public,storage
PGRST_DB_ANON_ROLE: anon
PGRST_JWT_SECRET: ${JWT_SECRET}
PGRST_DB_USE_LEGACY_GUCS: "false"
PGRST_APP_SETTINGS_JWT_SECRET: ${JWT_SECRET}
PGRST_APP_SETTINGS_JWT_EXP: 3600
# ════════════════════════════════════════════════════════════════════════
# Realtime — Postgres-Changes-Broadcast für Live-Sync
# ════════════════════════════════════════════════════════════════════════
realtime:
image: supabase/realtime:v2.30.34
container_name: rapport-realtime
restart: unless-stopped
depends_on:
db:
condition: service_healthy
environment:
PORT: 4000
DB_HOST: db
DB_PORT: 5432
DB_USER: supabase_admin
DB_PASSWORD: ${POSTGRES_PASSWORD}
DB_NAME: postgres
DB_AFTER_CONNECT_QUERY: 'SET search_path TO _realtime'
DB_ENC_KEY: supabaserealtime
API_JWT_SECRET: ${JWT_SECRET}
SECRET_KEY_BASE: ${JWT_SECRET}
ERL_AFLAGS: -proto_dist inet_tcp
ENABLE_TAILSCALE: "false"
DNS_NODES: "''"
command: >
sh -c "/app/bin/migrate && /app/bin/realtime eval 'Realtime.Release.seeds(Realtime.Repo)' && /app/bin/server"
# ════════════════════════════════════════════════════════════════════════
# Storage — Object-Storage für Bilder (Quittungen, Logos)
# ════════════════════════════════════════════════════════════════════════
storage:
image: supabase/storage-api:v1.11.13
container_name: rapport-storage
restart: unless-stopped
depends_on:
db:
condition: service_healthy
rest:
condition: service_started
environment:
ANON_KEY: ${ANON_KEY}
SERVICE_KEY: ${SERVICE_ROLE_KEY}
POSTGREST_URL: http://rest:3000
PGRST_JWT_SECRET: ${JWT_SECRET}
DATABASE_URL: postgres://supabase_storage_admin:${POSTGRES_PASSWORD}@db:5432/postgres
FILE_SIZE_LIMIT: 52428800
STORAGE_BACKEND: file
FILE_STORAGE_BACKEND_PATH: /var/lib/storage
TENANT_ID: stub
REGION: stub
GLOBAL_S3_BUCKET: stub
volumes:
- storage-data:/var/lib/storage
# ════════════════════════════════════════════════════════════════════════
# Kong — API-Gateway: bündelt alle Services unter einer URL
# ════════════════════════════════════════════════════════════════════════
kong:
image: kong:2.8.1
container_name: rapport-kong
restart: unless-stopped
depends_on:
- auth
- rest
- storage
- realtime
environment:
KONG_DATABASE: "off"
KONG_DECLARATIVE_CONFIG: /var/lib/kong/kong.yml
KONG_DNS_ORDER: LAST,A,CNAME
KONG_PLUGINS: request-transformer,cors,key-auth,acl,basic-auth
volumes:
- ./kong.yml:/var/lib/kong/kong.yml:ro
ports:
- "${KONG_HTTP_PORT:-8000}:8000"
- "${KONG_HTTPS_PORT:-8443}:8443"
# ════════════════════════════════════════════════════════════════════════
# Rapport Frontend — die React-App hinter nginx
# ════════════════════════════════════════════════════════════════════════
app:
build:
context: .
dockerfile: Dockerfile.app
args:
RAPPORT_APP_TAG: ${RAPPORT_APP_TAG:-main}
SUPABASE_URL: ${API_EXTERNAL_URL}
SUPABASE_ANON_KEY: ${ANON_KEY}
image: rapport-app:${RAPPORT_APP_TAG:-latest}
container_name: rapport-app
restart: unless-stopped
ports:
- "${APP_PORT:-8080}:80"
volumes:
postgres-data:
storage-data: