8cb92b9226
This is a clean, ready-to-deploy Matrix communication stack with: Features: - Matrix Synapse homeserver with PostgreSQL - Element Web client - Matrix Authentication Service (MAS) with OIDC - Authelia SSO with 2FA support - Caddy reverse proxy with automatic HTTPS - Bridges: Telegram, WhatsApp, Signal (pre-configured) Deployment Modes: - Local testing (all-in-one with self-signed certs) - Production (distributed 3-machine setup with Let's Encrypt) All Critical Bugfixes Applied: 1. Using example.test domains (not .localhost - public suffix list issue) 2. MAS assets resource enabled (fixes CSS 404 errors) 3. MAS fetch_userinfo enabled (required for Authelia claims) 4. Internal discovery URL for faster OIDC metadata fetching 5. Claims templates using preferred_username (Authelia compatible) 6. All redirect URIs configured in Authelia 7. Caddy CA certificate extraction automated 8. Correct email domains throughout Security: - All secrets generated dynamically on deployment - Cryptographically secure random generation (OpenSSL) - 4096-bit RSA keys for OIDC/JWT signing - Argon2 password hashing - No hardcoded secrets in repository Documentation: - BUGFIXES.md - Comprehensive troubleshooting guide - DEPLOYMENT_GUIDE.md - Step-by-step deployment manual - QUICK_REFERENCE.md - Command cheatsheet - README.md - Quick start guide - PRODUCTION.md - Production deployment guide Deployment: - Single command: ./deploy.sh - Fully automated configuration generation - ~10 minutes to complete setup State: Clean slate, ready for validation deployment
193 lines
4.5 KiB
YAML
193 lines
4.5 KiB
YAML
services:
|
|
# PostgreSQL Database
|
|
postgres:
|
|
image: postgres:16-alpine
|
|
container_name: matrix-postgres
|
|
restart: unless-stopped
|
|
environment:
|
|
POSTGRES_DB: synapse
|
|
POSTGRES_USER: synapse
|
|
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-changeme}
|
|
POSTGRES_INITDB_ARGS: --encoding=UTF-8 --lc-collate=C --lc-ctype=C
|
|
volumes:
|
|
- ./postgres/data:/var/lib/postgresql/data
|
|
- ./postgres/init:/docker-entrypoint-initdb.d
|
|
networks:
|
|
- matrix-network
|
|
healthcheck:
|
|
test: ["CMD-SHELL", "pg_isready -U synapse"]
|
|
interval: 10s
|
|
timeout: 5s
|
|
retries: 5
|
|
|
|
# Matrix Synapse Server
|
|
synapse:
|
|
image: matrixdotorg/synapse:latest
|
|
container_name: matrix-synapse
|
|
restart: unless-stopped
|
|
environment:
|
|
SYNAPSE_CONFIG_PATH: /data/homeserver.yaml
|
|
volumes:
|
|
- ./synapse/data:/data
|
|
# Ports exposed only to internal network - access via Caddy
|
|
expose:
|
|
- "8008"
|
|
networks:
|
|
- matrix-network
|
|
depends_on:
|
|
postgres:
|
|
condition: service_healthy
|
|
healthcheck:
|
|
test: ["CMD", "curl", "-f", "http://localhost:8008/health"]
|
|
interval: 30s
|
|
timeout: 10s
|
|
retries: 3
|
|
|
|
# Element Web Client
|
|
element:
|
|
image: vectorim/element-web:latest
|
|
container_name: matrix-element
|
|
restart: unless-stopped
|
|
volumes:
|
|
- ./element/config/config.json:/app/config.json:ro
|
|
# Accessed via Caddy
|
|
expose:
|
|
- "80"
|
|
networks:
|
|
- matrix-network
|
|
depends_on:
|
|
- synapse
|
|
|
|
# Redis for Authelia session storage
|
|
redis:
|
|
image: redis:7-alpine
|
|
container_name: matrix-redis
|
|
restart: unless-stopped
|
|
networks:
|
|
- matrix-network
|
|
healthcheck:
|
|
test: ["CMD", "redis-cli", "ping"]
|
|
interval: 10s
|
|
timeout: 5s
|
|
retries: 5
|
|
|
|
# Authelia SSO
|
|
authelia:
|
|
image: authelia/authelia:latest
|
|
container_name: matrix-authelia
|
|
restart: unless-stopped
|
|
environment:
|
|
TZ: Europe/Berlin
|
|
AUTHELIA_SESSION_SECRET: ${AUTHELIA_SESSION_SECRET}
|
|
AUTHELIA_STORAGE_ENCRYPTION_KEY: ${AUTHELIA_STORAGE_ENCRYPTION_KEY}
|
|
AUTHELIA_JWT_SECRET: ${AUTHELIA_JWT_SECRET}
|
|
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
|
|
volumes:
|
|
- ./authelia/config:/config
|
|
# Accessed via Caddy
|
|
expose:
|
|
- "9091"
|
|
networks:
|
|
- matrix-network
|
|
depends_on:
|
|
postgres:
|
|
condition: service_healthy
|
|
redis:
|
|
condition: service_healthy
|
|
|
|
# Matrix Authentication Service (MAS)
|
|
mas:
|
|
image: ghcr.io/element-hq/matrix-authentication-service:latest
|
|
container_name: matrix-mas
|
|
restart: unless-stopped
|
|
environment:
|
|
MAS_CONFIG: /config/config.yaml
|
|
volumes:
|
|
- ./mas/config:/config:ro
|
|
- ./mas/data:/data
|
|
# Accessed via Caddy
|
|
expose:
|
|
- "8080"
|
|
- "8081"
|
|
networks:
|
|
- matrix-network
|
|
depends_on:
|
|
postgres:
|
|
condition: service_healthy
|
|
authelia:
|
|
condition: service_started
|
|
healthcheck:
|
|
test: ["CMD", "curl", "-f", "http://localhost:8081/health"]
|
|
interval: 30s
|
|
timeout: 10s
|
|
retries: 3
|
|
|
|
# Caddy Reverse Proxy (HTTPS termination)
|
|
caddy:
|
|
image: caddy:2-alpine
|
|
container_name: matrix-caddy
|
|
restart: unless-stopped
|
|
ports:
|
|
- "443:443"
|
|
- "80:80"
|
|
- "2019:2019" # Admin API
|
|
volumes:
|
|
- ./caddy/Caddyfile:/etc/caddy/Caddyfile:ro
|
|
- ./caddy/data:/data
|
|
- ./caddy/config:/config
|
|
networks:
|
|
- matrix-network
|
|
depends_on:
|
|
- synapse
|
|
- element
|
|
- mas
|
|
- authelia
|
|
|
|
# mautrix-telegram Bridge
|
|
mautrix-telegram:
|
|
image: dock.mau.dev/mautrix/telegram:latest
|
|
container_name: matrix-bridge-telegram
|
|
restart: unless-stopped
|
|
volumes:
|
|
- ./bridges/telegram/config:/data
|
|
networks:
|
|
- matrix-network
|
|
depends_on:
|
|
synapse:
|
|
condition: service_healthy
|
|
|
|
# mautrix-whatsapp Bridge
|
|
mautrix-whatsapp:
|
|
image: dock.mau.dev/mautrix/whatsapp:latest
|
|
container_name: matrix-bridge-whatsapp
|
|
restart: unless-stopped
|
|
volumes:
|
|
- ./bridges/whatsapp/config:/data
|
|
networks:
|
|
- matrix-network
|
|
depends_on:
|
|
synapse:
|
|
condition: service_healthy
|
|
|
|
# mautrix-signal Bridge
|
|
mautrix-signal:
|
|
image: dock.mau.dev/mautrix/signal:latest
|
|
container_name: matrix-bridge-signal
|
|
restart: unless-stopped
|
|
volumes:
|
|
- ./bridges/signal/config:/data
|
|
networks:
|
|
- matrix-network
|
|
depends_on:
|
|
synapse:
|
|
condition: service_healthy
|
|
|
|
networks:
|
|
matrix-network:
|
|
driver: bridge
|
|
|
|
volumes:
|
|
postgres-data:
|
|
synapse-data:
|
|
mas-data:
|