version: '3.9'

services:
  paperless:
    image: paperlessngx/paperless-ngx:2.10.3
    environment:
      PAPERLESS_REDIS: redis://redis_master:6379
      PAPERLESS_DBHOST: postgresql_primary
      PAPERLESS_DBNAME: paperless
      PAPERLESS_DBUSER: postgres
      PAPERLESS_DBPASS_FILE: /run/secrets/pg_root_password
    secrets:
      - pg_root_password
    volumes:
      - paperless_data:/usr/src/paperless/data
      - paperless_media:/usr/src/paperless/media
    networks:
      - traefik-public
      - database-network
    deploy:
      labels:
        - traefik.enable=true
        - traefik.http.routers.paperless.rule=Host(`paperless.localhost`)
        - traefik.http.routers.paperless.entrypoints=websecure
        - traefik.http.routers.paperless.tls=true
        - traefik.http.services.paperless.loadbalancer.server.port=8000

volumes:
  paperless_data:
    driver: local
    driver_opts:
      type: nfs
      o: addr=omv800.local,nolock,soft,rw
      device: :/export/paperless/data
  paperless_media:
    driver: local
    driver_opts:
      type: nfs
      o: addr=omv800.local,nolock,soft,rw
      device: :/export/paperless/media

secrets:
  pg_root_password:
    external: true

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