# Matrix Synapse - Federated chat server
# Port: 8008
# Matrix homeserver for decentralized communication
version: "3.9"
services:
  synapse-db:
    image: postgres:15
    container_name: Synapse-DB
    hostname: synapse-db
    security_opt:
      - no-new-privileges:true
    healthcheck:
      test: ["CMD", "pg_isready", "-q", "-d", "synapsedb", "-U", "synapseuser"]
      timeout: 45s
      interval: 10s
      retries: 10
    user: 1026:100
    volumes:
      - /volume2/metadata/docker/synapse/db:/var/lib/postgresql/data
    environment:
      - POSTGRES_DB=synapsedb
      - POSTGRES_USER=synapseuser
      - POSTGRES_PASSWORD="REDACTED_PASSWORD"  # pragma: allowlist secret
      - POSTGRES_INITDB_ARGS=--encoding=UTF-8 --lc-collate=C --lc-ctype=C
    restart: unless-stopped

  synapse:
    image: matrixdotorg/synapse:latest
    container_name: Synapse
    hostname: synapse
    security_opt:
      - no-new-privileges:true
    user: 1026:100
    environment:
      - TZ=America/Los_Angeles
      - SYNAPSE_CONFIG_PATH=/data/homeserver.yaml
    volumes:
      - /volume2/metadata/docker/synapse/data:/data
    ports:
      - 8450:8008/tcp
    restart: unless-stopped
    depends_on:
      synapse-db:
        condition: service_started
