services:
  element-call-auth-service:
    image: ghcr.io/element-hq/lk-jwt-service:0.4.1
    container_name: element-call-jwt
    hostname: auth-server
    environment:
      - LK_JWT_PORT=8080
      - LIVEKIT_URL=https://${LIVEKIT_DOMAIN}/livekit/sfu
      - LIVEKIT_KEY=devkey
      - LIVEKIT_SECRET=${LIVEKIT_SECRET_KEY}
      - LIVEKIT_FULL_ACCESS_HOMESERVERS=${MATRIX_DOMAIN} 
    restart: always
    ports:
      - 8071:8080
  element-call-livekit:
    image: livekit/livekit-server:v1.9.11
    command: --config /etc/livekit.yaml
    ports:
      - "7880:7880/tcp"
      - "7881:7881/tcp"
      - "7882:7882/tcp"
      - "50100-50200:50100-50200/udp"
    restart: always
    volumes:
      - ${LIVEKIT_CONFIG_DIR}/config.yaml:/etc/livekit.yaml:ro
  mautrix-signal:
    container_name: mautrix-signal
    image: dock.mau.dev/mautrix/signal:v0.2601.0
    restart: always
    volumes:
      - ${MAUTRIX_SIGNAL_DATA_DIR}:/data
  mautrix-signal_db:
    image: docker.io/library/postgres:17
    restart: always
    volumes:
      - ${MAUTRIX_SIGNAL_POSTGRES_DATA_DIR}:/var/lib/postgresql/data
    environment:
      POSTGRES_DB: ${MAUTRIX_SIGNAL_POSTGRES_DB}
      POSTGRES_USER: ${MAUTRIX_SIGNAL_POSTGRES_USER}
      POSTGRES_PASSWORD: ${MAUTRIX_SIGNAL_POSTGRES_PASSWORD}
    ports:
      - 5439:5432
  mautrix-whatsapp:
    container_name: mautrix-whatsapp
    image: dock.mau.dev/mautrix/whatsapp:v0.2601.0
    #image: petersmit27/mautrix-whatsapp:latest
    restart: always
    volumes:
      - ${MAUTRIX_WHATSAPP_DATA_DIR}:/data
    depends_on:
      - mautrix-whatsapp_db
  mautrix-whatsapp_db:
    image: docker.io/library/postgres:17
    restart: always
    volumes:
      - ${MAUTRIX_WHATSAPP_POSTGRES_DATA_DIR}:/var/lib/postgresql/data
    environment:
      POSTGRES_DB: ${MAUTRIX_WHATSAPP_POSTGRES_DB}
      POSTGRES_USER: ${MAUTRIX_WHATSAPP_POSTGRES_USER}
      POSTGRES_PASSWORD: ${MAUTRIX_WHATSAPP_POSTGRES_PASSWORD}
    ports:
      - 5440:5432
  mas:
    image: ghcr.io/element-hq/matrix-authentication-service:1.9.0
    restart: always
    working_dir: /config
    volumes:
      - ${MAS_CONFIG_DIR}:/config
    environment:
      MAS_CONFIG: /config/config.yaml
    ports:
      - "8090:8090"
    depends_on:
      - mas_db
  mas_db:
    image: docker.io/library/postgres:17
    restart: always
    volumes:
      - ${MAS_POSTGRES_DATA_DIR}:/var/lib/postgresql/data
    environment:
      POSTGRES_DB: ${MAS_POSTGRES_DB}
      POSTGRES_USER: ${MAS_POSTGRES_USER}
      POSTGRES_PASSWORD: ${MAS_POSTGRES_PASSWORD}
    ports:
      - 5441:5432
  synapse_db:
    image: docker.io/library/postgres:17
    restart: always
    volumes:
      - ${SYNAPSE_POSTGRES_DATA_DIR}:/var/lib/postgresql/data
    environment:
      POSTGRES_DB: ${SYNAPSE_POSTGRES_DB}
      POSTGRES_USER: ${SYNAPSE_POSTGRES_USER}
      POSTGRES_PASSWORD: ${SYNAPSE_POSTGRES_PASSWORD}
      POSTGRES_INITDB_ARGS: '--encoding=UTF-8  --locale=C'
    ports:
      - 5442:5432
  synapse:
    container_name: synapse
    image: matrixdotorg/synapse:v1.145.0
    restart: always
    volumes:
      - ${SYNAPSE_CONFIG_DIR}:/data
    ports:
      - "8008:8008"
    depends_on:
      - synapse_db
      - mas
      - mautrix-whatsapp
  element-admin:
    image: oci.element.io/element-admin:0.1.10
    restart: unless-stopped
    ports:
      - "8079:8080"
    environment:
      - SERVER_NAME=${MATRIX_DOMAIN}
