From ad74825781f3b35c56233aa6f74367bd3d868a2e Mon Sep 17 00:00:00 2001 From: florianfederspiel Date: Wed, 3 Jun 2026 10:22:30 +0200 Subject: [PATCH] KI-AGENT: Matrix-Kommunikation im Selfhost-Bootstrap provisionieren --- .env.example | 1 + backend/src/modules/bootstrap.service.ts | 16 ++++++++++++++++ docker-compose.selfhost.yml | 9 +++++++++ scripts/selfhost-setup.sh | 1 + 4 files changed, 27 insertions(+) diff --git a/.env.example b/.env.example index 2f99de2..12f3189 100644 --- a/.env.example +++ b/.env.example @@ -117,6 +117,7 @@ FEDEO_BOOTSTRAP_ADMIN_FIRST_NAME=Admin FEDEO_BOOTSTRAP_ADMIN_LAST_NAME=Benutzer FEDEO_BOOTSTRAP_TENANT_NAME=Mein Unternehmen FEDEO_BOOTSTRAP_TENANT_SHORT=MEIN +FEDEO_BOOTSTRAP_MATRIX=true # FEDEO Matrix-Kommunikation # diff --git a/backend/src/modules/bootstrap.service.ts b/backend/src/modules/bootstrap.service.ts index 611577a..c1d3d3f 100644 --- a/backend/src/modules/bootstrap.service.ts +++ b/backend/src/modules/bootstrap.service.ts @@ -21,6 +21,7 @@ import { texttemplates, units, } from "../../db/schema" +import { matrixService } from "./matrix.service" const adminPermissions = [ "mcp.tokens.write", @@ -487,4 +488,19 @@ export async function runBootstrap(server: FastifyInstance) { await ensureTenantBaseData(server, tenant.id, adminUser.id) console.log("✅ Bootstrap-Grunddaten geprüft") + + if (process.env.FEDEO_BOOTSTRAP_MATRIX === "true") { + try { + const matrix = matrixService(server) + await matrix.provisionTenantRoom(adminUser.id, tenant.id, { + key: "allgemein", + name: "Allgemeiner Chat", + type: "general", + }) + console.log("✅ Bootstrap-Matrix-Kommunikation geprüft") + } catch (err) { + console.error("❌ Bootstrap-Matrix-Kommunikation fehlgeschlagen:", err) + throw err + } + } } diff --git a/docker-compose.selfhost.yml b/docker-compose.selfhost.yml index e7243a8..9bdc459 100644 --- a/docker-compose.selfhost.yml +++ b/docker-compose.selfhost.yml @@ -91,6 +91,8 @@ services: condition: service_healthy createbuckets: condition: service_completed_successfully + matrix-synapse: + condition: service_healthy environment: NODE_ENV: production FEDEO_RUN_MIGRATIONS: ${FEDEO_RUN_MIGRATIONS:-true} @@ -134,6 +136,7 @@ services: FEDEO_BOOTSTRAP_ADMIN_LAST_NAME: ${FEDEO_BOOTSTRAP_ADMIN_LAST_NAME:-Benutzer} FEDEO_BOOTSTRAP_TENANT_NAME: ${FEDEO_BOOTSTRAP_TENANT_NAME:-FEDEO} FEDEO_BOOTSTRAP_TENANT_SHORT: ${FEDEO_BOOTSTRAP_TENANT_SHORT:-FEDEO} + FEDEO_BOOTSTRAP_MATRIX: ${FEDEO_BOOTSTRAP_MATRIX:-true} MATRIX_HOMESERVER_URL: ${MATRIX_HOMESERVER_URL:-http://matrix-synapse:8008} MATRIX_SERVER_NAME: ${MATRIX_SERVER_NAME:-${DOMAIN}} MATRIX_RTC_HOST: ${MATRIX_RTC_HOST:-${DOMAIN}} @@ -301,6 +304,12 @@ services: exec /start.py volumes: - ./matrix/synapse:/data + healthcheck: + test: ["CMD-SHELL", "python -c \"import urllib.request; urllib.request.urlopen('http://localhost:8008/_matrix/client/versions', timeout=2)\""] + interval: 10s + timeout: 5s + retries: 30 + start_period: 20s labels: - traefik.enable=true - traefik.http.routers.fedeo-matrix.rule=Host(`${DOMAIN}`) && PathPrefix(`/_matrix`) diff --git a/scripts/selfhost-setup.sh b/scripts/selfhost-setup.sh index ecf8efc..87bac5f 100755 --- a/scripts/selfhost-setup.sh +++ b/scripts/selfhost-setup.sh @@ -370,6 +370,7 @@ FEDEO_BOOTSTRAP_ADMIN_FIRST_NAME=$(env_quote "$admin_first_name") FEDEO_BOOTSTRAP_ADMIN_LAST_NAME=$(env_quote "$admin_last_name") FEDEO_BOOTSTRAP_TENANT_NAME=$(env_quote "$tenant_name") FEDEO_BOOTSTRAP_TENANT_SHORT=$(env_quote "$tenant_short") +FEDEO_BOOTSTRAP_MATRIX=$(env_quote "true") MATRIX_SERVER_NAME=$(env_quote "$domain") MATRIX_POSTGRES_DB=$(env_quote "synapse")