version: "3.9"

# based on an example found here: https://jonnev.se/matrix-homeserver-with-docker/

services:
  nginx:
    image: nginx:1.15-alpine
    restart: unless-stopped
    volumes:
      - ./data/nginx:/etc/nginx/conf.d
      - ./data/certbot/conf:/etc/letsencrypt
      - ./data/www:/etc/www:ro
    ports:
      - "80:80"
      - "443:443"
    command: "/bin/sh -c 'while :; do sleep 6h & wait $${!}; nginx -s reload; done & nginx -g \"daemon off;\"'"
  # the certbot container won't start unless asked (like if we're renewing a cert)
  certbot:
    image: certbot/certbot
    restart: unless-stopped
    volumes:
      - ./data/certbot/conf:/etc/letsencrypt
      - ./data/certbot/www:/var/www/certbot
    profiles:
      - cert_renew  # don't start this container unless explicitly asked

  postgres:
    image: arm32v7/postgres:12.5  # postgres:12.5 on x86_64
    user: 1000:1000
    restart: unless-stopped
    networks:
      - synapse
    volumes:
     - ./data/postgres:/var/lib/postgresql/data
    environment:
     - POSTGRES_PASSWORD=some password
     - POSTGRES_USER=synapse
     - POSTGRES_INITDB_ARGS=--locale C --encoding UTF8
  synapse:
    image: matrixdotorg/synapse:v1.26.0  # later tags are recommended for x86_64
    restart: unless-stopped
    depends_on:
     - postgres
    networks:
      - default
      - synapse
    volumes:
     - ./data/synapse:/data
    environment:
     - UID=1000
     - GID=1000

  maubot:
    image: kylrth/maubot:latest  # dock.mau.dev/maubot/maubot:latest on x86_64
    restart: unless-stopped
    depends_on:
      - synapse
    volumes:
     - ./data/maubot:/data:z
    environment:
     - UID=1000
     - GID=1000

  registration:
    image: kylrth/matrix-registration  # zeratax/matrix-registration:v0.9.1 on x86_64
    restart: unless-stopped
    depends_on:
      - synapse
    volumes:
     - ./data/registration:/data
    user: 1000:1000
    command: serve

networks:
  synapse:
