version: "3.8"

services:
  broker:
    image: redis:7
    container_name: PaperlessNGX-REDIS
    command: ["redis-server", "--save", "60", "1", "--loglevel", "warning"]
    healthcheck:
      test: ["CMD", "redis-cli", "ping"]
      interval: 10s
      timeout: 3s
      retries: 5
    restart: unless-stopped

  db:
    image: postgres:16
    container_name: PaperlessNGX-DB
    environment:
      POSTGRES_DB: paperless
      POSTGRES_USER: paperless
      POSTGRES_PASSWORD: "REDACTED_PASSWORD"  # pragma: allowlist secret
    volumes:
      - /volume2/metadata/docker/paperless/postgres:/var/lib/postgresql/data
    restart: unless-stopped

  paperless:
    image: ghcr.io/paperless-ngx/paperless-ngx:latest
    container_name: PaperlessNGX
    depends_on:
      broker:
        condition: service_healthy
      db:
        condition: service_started
    environment:
      PUID: 1029
      PGID: 100
      TZ: America/Los_Angeles

      PAPERLESS_REDIS: redis://broker:6379
      PAPERLESS_DBHOST: db
      PAPERLESS_DBPORT: 5432
      PAPERLESS_DBNAME: paperless
      PAPERLESS_DBUSER: paperless
      PAPERLESS_DBPASS: paperless

      PAPERLESS_URL: http://paperless.vish.local
      PAPERLESS_OCR_LANGUAGE: eng

    volumes:
      - /volume2/metadata/docker/paperless/data:/usr/src/paperless/data
      - /volume2/metadata/docker/paperless/inbox:/usr/src/paperless/consume
      - /volume2/metadata/docker/paperless/documents:/usr/src/paperless/export
      - /volume2/metadata/docker/paperless/media:/usr/src/paperless/media

    ports:
      - "5890:8000"

    restart: unless-stopped
