services:
  synapse:
    image: docker.io/matrixdotorg/synapse:latest
    user: "1000"
    # Since synapse does not retry to connect to the database, restart upon
    # failure
    restart: unless-stopped
    entrypoint: /bin/bash
    command: >
      -c "nohup bash -c 'sleep 10; /config/delayed_accounts_creation.sh' \&
        ./start.py"

    # See the readme for a full documentation of the environment settings
    # NOTE: You must edit homeserver.yaml to use postgres, it defaults to sqlite
    environment:
      - SYNAPSE_CONFIG_PATH=/config/homeserver.yaml
    volumes:
      # You may either store all the files in a local folder
      - ./storage/synapse:/data
      - ./docker/synapse:/config:ro
      # .. or you may split this between different storage points
      # - ./files:/data
      # - /path/to/ssd:/data/uploads
      # - /path/to/large_hdd:/data/media
    depends_on:
      - db
    # In order to expose Synapse, remove one of the following, you might for
    # instance expose the TLS port directly:
    ports:
      - 8448:8448/tcp

  db:
    image: docker.io/postgres:17-alpine
    user: "1000"
    environment:
      - POSTGRES_USER=synapse
      - POSTGRES_PASSWORD=changeme
      # ensure the database gets created correctly
      # https://element-hq.github.io/synapse/latest/postgres.html#set-up-database
      - POSTGRES_INITDB_ARGS=--encoding=UTF-8 --lc-collate=C --lc-ctype=C
    volumes:
      # You may store the database tables in a local folder..
      - ./storage/postgres:/var/lib/postgresql/data
      # .. or store them on some high performance storage for better results
      # - /path/to/ssd/storage:/var/lib/postgresql/data

  element:
    image: docker.io/vectorim/element-web
    ports:
      - 8080:80/tcp
    volumes:
      - ./docker/element/config.json:/app/config.json:ro

  oidc:
    image: dexidp/dex
    ports:
      - 9001:9001
    volumes:
      - ./docker/dex:/conf:ro
    command: ["dex", "serve", "/conf/dex.config.yaml"]

  minio:
    image: quay.io/minio/minio
    command: minio server --console-address ":9002" /data
    ports:
      - 9000:9000/tcp
      - 9002:9002/tcp
    environment:
      MINIO_ROOT_USER: minioadmin
      MINIO_ROOT_PASSWORD: minioadmin
    volumes:
      # You may store the database tables in a local folder..
      - ./storage/minio:/data

  redis:
    image: redis:alpine
    command: redis-server --requirepass ${REDIS_PASS:-secretredis}
    ports:
      - 6379:6379
    volumes:
      - ./storage/redis-data:/data
      - ./storage/redis-conf:/usr/local/etc/redis/redis.conf