version: "3.8"

services:
  conduit:
    image: docker.io/girlbossceo/conduit:v0.8.0
    container_name: timmy-conduit
    restart: unless-stopped
    volumes:
      - ./conduit.toml:/etc/conduit/conduit.toml:ro
      - conduit-data:/var/lib/matrix-conduit
    environment:
      - CONDUIT_CONFIG=/etc/conduit/conduit.toml
      # Override secrets via env (see .env)
      - CONDUIT_REGISTRATION_TOKEN=${CONDUIT_REGISTRATION_TOKEN}
      - CONDUIT_DATABASE_PASSWORD=${CONDUIT_DATABASE_PASSWORD}
    ports:
      # Only expose on localhost; reverse proxy forwards from 443
      - "127.0.0.1:6167:6167"
    networks:
      - matrix
    healthcheck:
      test: ["CMD", "wget", "-q", "--spider", "http://127.0.0.1:6167/_matrix/static/"]
      interval: 30s
      timeout: 5s
      retries: 3
      start_period: 10s

  # Optional: Element Web client (self-hosted)
  element-web:
    image: vectorim/element-web:latest
    container_name: timmy-element
    restart: unless-stopped
    volumes:
      - ./element-config.json:/app/config.json:ro
    environment:
      - default_server_config.homeserver.base_url=https://${MATRIX_DOMAIN}
      - default_server_config.homeserver.server_name=${MATRIX_DOMAIN}
    ports:
      - "127.0.0.1:8080:80"
    networks:
      - matrix
    profiles:
      - element  # docker compose --profile element up -d

volumes:
  conduit-data:
    driver: local

networks:
  matrix:
    driver: bridge
