version: '3'
services:
  matrix-postgres:
    image: postgres:13
    restart: unless-stopped
    hostname: matrix-postgres
    environment:
      - POSTGRES_PASSWORD=$POSTGRES_PASS
      - POSTGRES_USER=synapse_user
      - POSTGRES_DB=synapse
      - POSTGRES_INITDB_ARGS=--encoding='UTF8' --lc-collate='C' --lc-ctype='C'
    volumes:
      - ./.psqlrc:/root/.psqlrc:ro
  synapse:
    image: matrixdotorg/synapse:v1.31.0
    restart: unless-stopped
    volumes:
      - /srv/matrix:/data
      - /srv/matrix/matrix-appservice-irc:/matrix-appservice-irc
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.synapse.rule=Host(`synapse.$DOMAIN_NAME`)"
      - "traefik.http.routers.synapse.entrypoints=websecure"
      - "traefik.http.routers.synapse.tls.certresolver=letsencr"
      - "traefik.http.services.synapse.loadbalancer.server.port=8008"
    environment:
      - SYNAPSE_CONFIG_DIR=/data
      - SYNAPSE_CONFIG_PATH=/data/homeserver.yaml
      - UID=1000
      - GID=1000
      - TZ=Europe/Paris
    # networks:
    #   - default
    #   - $DEFAULT_NETWORK
  redis:
    image: redis:6.2.1
    restart: unless-stopped

networks:
  default:
    external:
      name: $DEFAULT_NETWORK
  # matrix-postgres:
  #   image: postgres:13
  #   restart: unless-stopped
  #   hostname: matrix-postgres
  #   environment:
  #     - POSTGRES_PASSWORD=$POSTGRES_PASS
  #     - POSTGRES_USER=synapse_user
  #     - POSTGRES_DB=synapse
  #     - POSTGRES_INITDB_ARGS=--encoding='UTF8' --lc-collate='C' --lc-ctype='C'
  #   volumes:
  #     - ./.psqlrc:/root/.psqlrc:ro
  # synapse:
  #     image: 'matrixdotorg/synapse:latest'
  #     volumes:
  #         - '/srv/matrix:/data'
  #     environment:
  #         - SYNAPSE_SERVER_NAME=matrix.$DOMAIN_NAME
  #         - SYNAPSE_REPORT_STATS=yes
  #         - UID=1000
  #         - GID=1000