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:
Executable
+64
@@ -0,0 +1,64 @@
|
||||
#!/usr/bin/env bash
|
||||
# Postgres-Init-Script — läuft beim ersten Start des db-Containers.
|
||||
#
|
||||
# 1. Legt die Supabase-Standard-Rollen an (anon, authenticated, service_role,
|
||||
# supabase_auth_admin, supabase_storage_admin, authenticator).
|
||||
# Diese referenzieren die in den Rapport-Migrations definierten Policies.
|
||||
# 2. Wendet alle Rapport-Migrations aus ./migrations/ in alphabetischer
|
||||
# Reihenfolge an.
|
||||
#
|
||||
# Nach diesem Script ist die DB einsatzbereit.
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
echo "→ Supabase-Standard-Rollen anlegen…"
|
||||
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname postgres <<-EOSQL
|
||||
-- Standard-Rollen (idempotent)
|
||||
do \$\$ begin
|
||||
if not exists (select 1 from pg_roles where rolname = 'anon') then
|
||||
create role anon nologin noinherit;
|
||||
end if;
|
||||
if not exists (select 1 from pg_roles where rolname = 'authenticated') then
|
||||
create role authenticated nologin noinherit;
|
||||
end if;
|
||||
if not exists (select 1 from pg_roles where rolname = 'service_role') then
|
||||
create role service_role nologin noinherit bypassrls;
|
||||
end if;
|
||||
if not exists (select 1 from pg_roles where rolname = 'authenticator') then
|
||||
execute format('create role authenticator noinherit login password %L', current_setting('rapport.postgres_password', true));
|
||||
end if;
|
||||
if not exists (select 1 from pg_roles where rolname = 'supabase_auth_admin') then
|
||||
execute format('create role supabase_auth_admin login password %L', current_setting('rapport.postgres_password', true));
|
||||
end if;
|
||||
if not exists (select 1 from pg_roles where rolname = 'supabase_storage_admin') then
|
||||
execute format('create role supabase_storage_admin login password %L', current_setting('rapport.postgres_password', true));
|
||||
end if;
|
||||
if not exists (select 1 from pg_roles where rolname = 'supabase_admin') then
|
||||
execute format('create role supabase_admin superuser login password %L', current_setting('rapport.postgres_password', true));
|
||||
end if;
|
||||
end \$\$;
|
||||
|
||||
grant anon to authenticator;
|
||||
grant authenticated to authenticator;
|
||||
grant service_role to authenticator;
|
||||
|
||||
-- auth-Schema (für GoTrue)
|
||||
create schema if not exists auth authorization supabase_auth_admin;
|
||||
|
||||
-- storage-Schema (für Storage-Service)
|
||||
create schema if not exists storage authorization supabase_storage_admin;
|
||||
|
||||
-- pgcrypto + andere Extensions
|
||||
create extension if not exists pgcrypto;
|
||||
create extension if not exists "uuid-ossp";
|
||||
EOSQL
|
||||
|
||||
echo "→ Rapport-Migrations applizieren…"
|
||||
for f in /docker-entrypoint-initdb.d/migrations/*.sql; do
|
||||
if [ -f "$f" ]; then
|
||||
echo " → $(basename "$f")"
|
||||
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname postgres -f "$f"
|
||||
fi
|
||||
done
|
||||
|
||||
echo "✓ DB-Initialisierung abgeschlossen."
|
||||
Reference in New Issue
Block a user