version: "3.4"
services:
  broker:
    image: redis:6.0
    restart: unless-stopped
    volumes:
      - redisdata:/data
      
  webserver:
    image: ghcr.io/paperless-ngx/paperless-ngx:latest
    #image: jonaswinkler/paperless-ng:latest
    restart: unless-stopped
    depends_on:
      - broker
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:8000"]
      interval: 30s
      timeout: 10s
      retries: 5
    volumes:
      - data:/usr/src/paperless/data
      - media:/usr/src/paperless/media
      - export:/usr/src/paperless/export
      - consume:/usr/src/paperless/consume
    environment:
      PAPERLESS_REDIS: redis://broker:6379
      PAPERLESS_SECRET_KEY: <...>
      # OCR
      PAPERLESS_OCR_LANGUAGE: deu
      PAPERLESS_OCR_MODE: skip
      PAPERLESS_OCR_CLEAN: clean
      PAPERLESS_OCR_DESKEW: "true"
      # parsing and converting “Office” documents
      PAPERLESS_TIKA_ENABLED: 1
      PAPERLESS_TIKA_GOTENBERG_ENDPOINT: http://gotenberg:3000
      PAPERLESS_TIKA_ENDPOINT: http://tika:9998
      # tweaks
      PAPERLESS_TASK_WORKERS: 2
      PAPERLESS_THREADS_PER_WORKER: 2
      PAPERLESS_TIME_ZONE: Europe/Berlin
      PAPERLESS_CONSUMER_RECURSIVE: "true"
      PAPERLESS_CONSUMER_SUBDIRS_AS_TAGS: "true"
      # https://paperless-ng.readthedocs.io/en/latest/advanced_usage.html#advanced-file-name-handling
      # https://paperless-ng.readthedocs.io/en/latest/administration.html#utilities-renamer
      PAPERLESS_FILENAME_FORMAT: "{correspondent}/{document_type}/{created_year}-{created_month}-{created_day} {title}"
      PAPERLESS_FILENAME_DATE_ORDER: YMD
      PAPERLESS_DATE_ORDER: DMY
      # ngx
      PAPERLESS_TRASH_DIR: "../media/trash"
    networks:
      - default

  gotenberg:
    image: thecodingmachine/gotenberg
    restart: unless-stopped
    environment:
      DISABLE_GOOGLE_CHROME: 1

  tika:
    image: apache/tika
    restart: unless-stopped

volumes:
  data:
  media:
  export:
  consume:
  redisdata: