version: '3.9'

services:
  appflowy:
    image: ghcr.io/appflowy-io/appflowy-cloud:0.3.5
    environment:
      DATABASE_URL_FILE: /run/secrets/appflowy_db_url
      REDIS_URL: redis://redis_master:6379
      STORAGE_ENDPOINT: http://minio:9000
      STORAGE_BUCKET: appflowy
      STORAGE_ACCESS_KEY_FILE: /run/secrets/minio_access_key
      STORAGE_SECRET_KEY_FILE: /run/secrets/minio_secret_key
    secrets:
      - appflowy_db_url
      - minio_access_key
      - minio_secret_key
    networks:
      - traefik-public
      - database-network
    depends_on:
      - minio
    deploy:
      labels:
        - traefik.enable=true
        - traefik.http.routers.appflowy.rule=Host(`appflowy.localhost`)
        - traefik.http.routers.appflowy.entrypoints=websecure
        - traefik.http.routers.appflowy.tls=true
        - traefik.http.services.appflowy.loadbalancer.server.port=8000

  minio:
    image: quay.io/minio/minio:RELEASE.2024-05-10T01-41-38Z
    command: server /data --console-address ":9001"
    environment:
      MINIO_ROOT_USER_FILE: /run/secrets/minio_access_key
      MINIO_ROOT_PASSWORD_FILE: /run/secrets/minio_secret_key
    secrets:
      - minio_access_key
      - minio_secret_key
    volumes:
      - appflowy_minio:/data
    networks:
      - traefik-public
    deploy:
      labels:
        - traefik.enable=true
        - traefik.http.routers.minio.rule=Host(`minio.localhost`)
        - traefik.http.routers.minio.entrypoints=websecure
        - traefik.http.routers.minio.tls=true
        - traefik.http.services.minio.loadbalancer.server.port=9001

volumes:
  appflowy_minio:
    driver: local
    driver_opts:
      type: nfs
      o: addr=omv800.local,nolock,soft,rw
      device: :/srv/mergerfs/DataPool/appflowy

secrets:
  appflowy_db_url:
    external: true
  minio_access_key:
    external: true
  minio_secret_key:
    external: true

networks:
  traefik-public:
    external: true
  database-network:
    external: true
