services:
  postgres:
    image: postgres:16-alpine
    security_opt: [apparmor=unconfined]
    restart: unless-stopped
    volumes:
      - ./data/postgres:/var/lib/postgresql/data
    environment:
      POSTGRES_DB: synapse
      POSTGRES_USER: synapse
      POSTGRES_PASSWORD: changeme_matrix_db_pass
    healthcheck:
      test: ["CMD", "pg_isready", "-U", "synapse"]
      interval: 10s
      timeout: 5s
      retries: 5

  synapse:
    image: matrixdotorg/synapse:latest
    security_opt: [apparmor=unconfined]
    restart: unless-stopped
    ports:
      - "8008:8008"
    volumes:
      - ./data:/data
    environment:
      SYNAPSE_SERVER_NAME: dd-matrix.netbird.selfhosted
      SYNAPSE_REPORT_STATS: "no"
    depends_on:
      postgres:
        condition: service_healthy

  element:
    image: vectorim/element-web:latest
    security_opt: [apparmor=unconfined]
    restart: unless-stopped
    ports:
      - "8080:80"
    volumes:
      - ./element-config:/app/config
