#version: "3.4"
services:
  broker:
    image: docker.io/library/redis:7
    restart: unless-stopped
    volumes:
      - redisdata:/data
    networks:
      - tnet
  webserver:
    image: ghcr.io/paperless-ngx/paperless-ngx:latest
    restart: unless-stopped
    depends_on:
      - broker
    ports:
      - 8200:8000
    healthcheck:
      test:
        - CMD
        - curl
        - -fs
        - -S
        - --max-time
        - "2"
        - http://localhost:8000
      interval: 30s
      timeout: 10s
      retries: 5
    volumes:
      - data:/usr/src/paperless/data
      - media:/usr/src/paperless/media
      - /mnt/documents/paperless/export:/usr/src/paperless/export
      - /mnt/documents/paperless/consume:/usr/src/paperless/consume
    # env_file: docker-compose.env
    environment:
      PAPERLESS_REDIS: redis://broker:6379
      PAPERLESS_DBHOST: 10.0.50.60
      PAPERLESS_DBPORT: 5432
      PAPERLESS_DBNAME: paperless-ng
      PAPERLESS_DBUSER: paperless-ng
      PAPERLESS_DBPASS: paperless-ng
      # PAPERLESS_MEDIA_ROOT=/data/media
      PAPERLESS_CONSUMPTION_DIR: /usr/src/paperless/consume
      PAPERLESS_EXPORT_DIR: /usr/src/paperless/export
      PAPERLESS_CONSUMER_POLLING: 30
      # PAPERLESS_DATA_DIR=/config
    labels:
      - homepage.group=Media
      - homepage.name=PaperlessNGX
      - homepage.icon=mdi-file-cabinet
      - homepage.description=Document Store (esh)
      - homepage.href=http://10.0.50.45:8200
      - homepage.sitemonitor=http://10.0.50.45:8200
      - homepage.widget.type=paperlessngx
      - homepage.widget.url=http://10.0.50.45:8200
      - homepage.widget.key=${API_KEY}
    networks:
      - tnet
    env_file:
      - .env
  backup:
    image: offen/docker-volume-backup:latest
    restart: always
    volumes:
      # volumes to backup.
      - data:/backup/paperless-data:ro
      - media:/backup/paperless-media:ro
      - redisdata:/backup/paperless-redisdata:ro
      - /mnt/backup/docker/esh-vm-docker/paperless:/archive
      # can omit below if not stopping service.
      # - /var/run/docker.sock:/var/run/docker.sock:ro
    env_file:
      - .env
    networks:
      - tnet
networks:
  tnet:
    name: traefik-net
    external: true
volumes:
  data: null
  media: null
  redisdata: null
