# Configuration for paperless-ngx setup

# Name of the big-bear-paperless-ngx application
name: big-bear-paperless-ngx
# Service definitions for the big-bear-paperless-ngx application
services:
  # Service name: big-bear-paperless-ngx
  # The `big-bear-paperless-ngx` service definition
  big-bear-paperless-ngx:
    # Name of the container
    container_name: big-bear-paperless-ngx
    # Image to be used for the container
    image: ghcr.io/paperless-ngx/paperless-ngx:2.20.15
    # Container restart policy
    restart: unless-stopped
    # environment variables
    environment:
      PAPERLESS_REDIS: redis://big-bear-paperless-ngx-broker:6379
      PAPERLESS_DBHOST: big-bear-paperless-ngx-db
      PAPERLESS_DBUSER: bigbear
      PAPERLESS_DBPASS: c6e74adb-3fce-4318-b657-4bdc0858fcac
      PAPERLESS_ADMIN_USER: bigbear
      PAPERLESS_ADMIN_PASSWORD: c22e92a6-2a3d-4edf-a98e-4044834daea6
      PAPERLESS_TIKA_ENABLED: "true"
      PAPERLESS_TIKA_GOTENBERG_ENDPOINT: http://big-bear-paperless-ngx-gotenberg:3000
      PAPERLESS_TIKA_ENDPOINT: http://big-bear-paperless-ngx-tika:9998
      PAPERLESS_URL: http://[YOUR_IP]:8000
      COMPOSE_PROJECT_NAME: big-bear-paperless-ngx
      PAPERLESS_CSRF_TRUSTED_ORIGINS: http://[YOUR_IP]:8000
    # Volumes to be mounted to the container
    volumes:
      - /DATA/AppData/$AppID/paperless/data:/usr/src/paperless/data
      - /DATA/AppData/$AppID/paperless/media:/usr/src/paperless/media
      - /DATA/AppData/$AppID/paperless/export:/usr/src/paperless/export
      - /DATA/AppData/$AppID/paperless/consume:/usr/src/paperless/consume
      - /DATA/AppData/$AppID/paperless/tmp:/tmp
    # Ports mapping between host and container
    ports:
      # Mapping port 8000 of the host to port 8000 of the container
      - "8000:8000"
    depends_on:
      - big-bear-paperless-ngx-db
      - big-bear-paperless-ngx-broker
    networks:
      - big-bear-paperless-ngx-network
    x-casaos:
      envs:
        - container: PAPERLESS_REDIS
          description:
            en_us: 'Container Variable: PAPERLESS_REDIS'
        - container: PAPERLESS_DBHOST
          description:
            en_us: 'Container Variable: PAPERLESS_DBHOST'
        - container: PAPERLESS_DBUSER
          description:
            en_us: 'Container Variable: PAPERLESS_DBUSER'
        - container: PAPERLESS_DBPASS
          description:
            en_us: 'Container Variable: PAPERLESS_DBPASS'
        - container: PAPERLESS_ADMIN_USER
          description:
            en_us: 'Container Variable: PAPERLESS_ADMIN_USER'
        - container: PAPERLESS_ADMIN_PASSWORD
          description:
            en_us: 'Container Variable: PAPERLESS_ADMIN_PASSWORD'
        - container: PAPERLESS_TIKA_ENABLED
          description:
            en_us: 'Container Variable: PAPERLESS_TIKA_ENABLED'
        - container: PAPERLESS_TIKA_GOTENBERG_ENDPOINT
          description:
            en_us: 'Container Variable: PAPERLESS_TIKA_GOTENBERG_ENDPOINT'
        - container: PAPERLESS_TIKA_ENDPOINT
          description:
            en_us: 'Container Variable: PAPERLESS_TIKA_ENDPOINT'
        - container: PAPERLESS_URL
          description:
            en_us: 'Container Variable: PAPERLESS_URL'
        - container: COMPOSE_PROJECT_NAME
          description:
            en_us: 'Container Variable: COMPOSE_PROJECT_NAME'
        - container: PAPERLESS_CSRF_TRUSTED_ORIGINS
          description:
            en_us: 'Container Variable: PAPERLESS_CSRF_TRUSTED_ORIGINS'
      volumes:
        - container: /usr/src/paperless/data
          description:
            en_us: 'Container Path: /usr/src/paperless/data'
        - container: /usr/src/paperless/media
          description:
            en_us: 'Container Path: /usr/src/paperless/media'
        - container: /usr/src/paperless/export
          description:
            en_us: 'Container Path: /usr/src/paperless/export'
        - container: /usr/src/paperless/consume
          description:
            en_us: 'Container Path: /usr/src/paperless/consume'
        - container: /tmp
          description:
            en_us: 'Container Path: /tmp'
      ports:
        - container: "8000"
          description:
            en_us: 'Container Port: 8000'
  big-bear-paperless-ngx-broker:
    container_name: big-bear-paperless-ngx-broker
    image: docker.io/library/redis:8.8.0
    restart: unless-stopped
    volumes:
      - /DATA/AppData/$AppID/redis:/data
    networks:
      - big-bear-paperless-ngx-network
    x-casaos:
      volumes:
        - container: /data
          description:
            en_us: 'Container Path: /data'
  # The PostgreSQL database service is used to store the data for the paperless-ngx service.
  big-bear-paperless-ngx-db:
    # Container name
    container_name: big-bear-paperless-ngx-db
    # Image to be used for the container
    image: library/postgres:16
    # Container restart policy
    restart: unless-stopped
    # Volumes to be mounted to the container
    volumes:
      - /DATA/AppData/$AppID/postgres:/var/lib/postgresql/data
    # Environment variables
    environment:
      # PostgreSQL database name
      POSTGRES_DB: paperless
      # PostgreSQL database user
      POSTGRES_USER: bigbear
      # PostgreSQL database password
      POSTGRES_PASSWORD: c6e74adb-3fce-4318-b657-4bdc0858fcac
    # Networks to be used for the service
    networks:
      - big-bear-paperless-ngx-network
    x-casaos:
      envs:
        - container: POSTGRES_DB
          description:
            en_us: 'Container Variable: POSTGRES_DB'
        - container: POSTGRES_USER
          description:
            en_us: 'Container Variable: POSTGRES_USER'
        - container: POSTGRES_PASSWORD
          description:
            en_us: 'Container Variable: POSTGRES_PASSWORD'
      volumes:
        - container: /var/lib/postgresql/data
          description:
            en_us: 'Container Path: /var/lib/postgresql/data'
  # The gotenberg service is used for converting documents to PDFs. It is
  # configured to disable JavaScript and only allow access to the
  # /tmp directory to prevent potential security issues.
  big-bear-paperless-ngx-gotenberg:
    container_name: big-bear-paperless-ngx-gotenberg
    image: gotenberg/gotenberg:8.34
    restart: unless-stopped
    # The gotenberg chromium route is used to convert .eml files. We do not
    # want to allow external content like tracking pixels or even javascript.
    # Therefore, we disable JavaScript and only allow access to the
    # /tmp directory.
    command:
      - "gotenberg"
      - "--chromium-disable-javascript=true"
      - "--chromium-allow-list=file:///tmp/.*"
    networks:
      - big-bear-paperless-ngx-network
  # The Tika service is used to extract text from files. It is based on the
  # Apache Tika project and is configured to use the minimal image.
  big-bear-paperless-ngx-tika:
    container_name: big-bear-paperless-ngx-tika
    image: apache/tika:3.3.1.0
    restart: unless-stopped
    # Volumes to be mounted to the container
    volumes:
      - /DATA/AppData/$AppID/tika/tmp:/tmp
    # The Tika service is connected to the big-bear-paperless-ngx-network
    # network.
    networks:
      - big-bear-paperless-ngx-network
    x-casaos:
      volumes:
        - container: /tmp
          description:
            en_us: 'Container Path: /tmp'
# Define a network for the paperless-ngx services to communicate with
# each other. This network is a bridge network, which means that it is
# not isolated from the host's network stack.
networks:
  big-bear-paperless-ngx-network:
    driver: bridge
x-casaos:
  # Supported CPU architectures for this application
  architectures:
    - amd64
    - arm64
  # Main service for this application
  main: big-bear-paperless-ngx
  # Detailed description for the application
  description:
    en_us: Paperless-ngx is a community-supported open-source document management system that transforms your physical documents into a searchable online archive so you can keep, well, less paper.
  # Brief tagline for the application
  tagline:
    en_us: Paperless-ngx
  # Developer's information
  developer: paperless-ngx
  # Author of this particular configuration
  author: BigBearTechWorld
  # Icon URL for the application
  icon: https://cdn.jsdelivr.net/gh/selfhst/icons/png/paperless-ngx.png
  # Thumbnail image for the application (if any)
  thumbnail: ""
  # Installation tips
  tips:
    before_install:
      en_us: |
        Read this before installing: https://community.bigbeartechworld.com/t/added-paperlessngx-to-bigbearcasaos/1954#p-3625-documentation-4
  # Title for the application
  title:
    en_us: Paperless-ngx
  # Category under which the application falls
  category: BigBearCasaOS
  # Default port mapping for the application
  port_map: "8000"
