From bc44e2c159ac53804aaad4c200ef88429ea84d74 Mon Sep 17 00:00:00 2001 From: Siddhartha Golu Date: Fri, 11 Aug 2023 18:21:23 +0000 Subject: [PATCH] add paperless config also add the rclone mount script which mounts the primary storage from backblaze b2 --- paperless-ngx/.env | 49 +++++++++++++++++ paperless-ngx/docker-compose.yml | 90 ++++++++++++++++++++++++++++++++ paperless-ngx/mount-rclone.sh | 1 + 3 files changed, 140 insertions(+) create mode 100644 paperless-ngx/.env create mode 100644 paperless-ngx/docker-compose.yml create mode 100755 paperless-ngx/mount-rclone.sh diff --git a/paperless-ngx/.env b/paperless-ngx/.env new file mode 100644 index 0000000..561708e --- /dev/null +++ b/paperless-ngx/.env @@ -0,0 +1,49 @@ +# The UID and GID of the user used to run paperless in the container. Set this +# to your UID and GID on the host so that you have write access to the +# consumption directory. +USERMAP_UID=1000 +USERMAP_GID=1000 + +# Additional languages to install for text recognition, separated by a +# whitespace. Note that this is +# different from PAPERLESS_OCR_LANGUAGE (default=eng), which defines the +# language used for OCR. +# The container installs English, German, Italian, Spanish and French by +# default. +# See https://packages.debian.org/search?keywords=tesseract-ocr-&searchon=names&suite=buster +# for available languages. +#PAPERLESS_OCR_LANGUAGES=tur ces + +############################################################################### +# Paperless-specific settings # +############################################################################### + +# All settings defined in the paperless.conf.example can be used here. The +# Docker setup does not use the configuration file. +# A few commonly adjusted settings are provided below. + +# This is required if you will be exposing Paperless-ngx on a public domain +# (if doing so please consider security measures such as reverse proxy) +PAPERLESS_URL=https://sub.domain.com +# PAPERLESS_CSRF_TRUSTED_ORIGINS=https://docs.siddharthagolu.com +# PAPERLESS_ALLOWED_HOSTS=https://docs.siddharthagolu.com + +# Adjust this key if you plan to make paperless available publicly. It should +# be a very long sequence of random characters. You don't need to remember it. +PAPERLESS_SECRET_KEY=super-secret-key + +# Use this variable to set a timezone for the Paperless Docker containers. If not specified, defaults to UTC. +PAPERLESS_TIME_ZONE=Asia/Kolkata + +# The default language to use for OCR. Set this to the language most of your +# documents are written in. +PAPERLESS_OCR_LANGUAGE=eng + +# Set if accessing paperless via a domain subpath e.g. https://domain.com/PATHPREFIX and using a reverse-proxy like traefik or nginx +#PAPERLESS_FORCE_SCRIPT_NAME=/PATHPREFIX +#PAPERLESS_STATIC_URL=/PATHPREFIX/static/ # trailing slash required + + +POSTGRES_DB=paperless +POSTGRES_USER=paperless +POSTGRES_PASSWORD=changeme diff --git a/paperless-ngx/docker-compose.yml b/paperless-ngx/docker-compose.yml new file mode 100644 index 0000000..7181648 --- /dev/null +++ b/paperless-ngx/docker-compose.yml @@ -0,0 +1,90 @@ +# docker-compose file for running paperless from the Docker Hub. +# This file contains everything paperless needs to run. +# Paperless supports amd64, arm and arm64 hardware. +# +# All compose files of paperless configure paperless in the following way: +# +# - Paperless is (re)started on system boot, if it was running before shutdown. +# - Docker volumes for storing data are managed by Docker. +# - Folders for importing and exporting files are created in the same directory +# as this file and mounted to the correct folders inside the container. +# - Paperless listens on port 8000. +# +# In addition to that, this docker-compose file adds the following optional +# configurations: +# +# - Instead of SQLite (default), PostgreSQL is used as the database server. +# +# To install and update paperless with this file, do the following: +# +# - Copy this file as 'docker-compose.yml' and the files 'docker-compose.env' +# and '.env' into a folder. +# - Run 'docker-compose pull'. +# - Run 'docker-compose run --rm webserver createsuperuser' to create a user. +# - Run 'docker-compose up -d'. +# +# For more extensive installation and update instructions, refer to the +# documentation. + +version: "3.4" +services: + broker: + image: docker.io/library/redis:7 + container_name: paperless-broker + restart: unless-stopped + volumes: + - redisdata:/data + networks: + - proxy-network + - internal + + db: + image: docker.io/library/postgres:15 + container_name: paperless-db + restart: unless-stopped + volumes: + - pgdata:/var/lib/postgresql/data + environment: + POSTGRES_DB: ${POSTGRES_DB} + POSTGRES_USER: ${POSTGRES_USER} + POSTGRES_PASSWORD: ${POSTGRES_PASSWORD} + networks: + - internal + + webserver: + image: ghcr.io/paperless-ngx/paperless-ngx:1.16 + container_name: paperless-app + restart: unless-stopped + depends_on: + - db + - broker + ports: + - "8000: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 + - ./export:/usr/src/paperless/export + - ./consume:/usr/src/paperless/consume + env_file: .env + environment: + PAPERLESS_REDIS: redis://broker:6379 + PAPERLESS_DBHOST: db + PAPERLESS_DBUSER: ${POSTGRES_USER} + PAPERLESS_DBPASS: ${POSTGRES_PASSWORD} + networks: + - internal + - proxy-network + +volumes: + pgdata: + redisdata: + +networks: + proxy-network: + external: true + internal: diff --git a/paperless-ngx/mount-rclone.sh b/paperless-ngx/mount-rclone.sh new file mode 100755 index 0000000..0d478c3 --- /dev/null +++ b/paperless-ngx/mount-rclone.sh @@ -0,0 +1 @@ +rclone mount backblaze:selfhost-backups/paperless-ngx/media /home/opc/paperless-ngx/media/ --no-checksum --use-server-modtime --no-gzip-encoding --no-update-modtime --no-seek --modify-window 2m --allow-other --allow-non-empty --dir-cache-time 30m --cache-read-retries 15 --cache-db-purge --timeout 30m --vfs-cache-mode full --vfs-read-chunk-size 2M --vfs-read-chunk-size-limit 5M --vfs-cache-max-age 30m --attr-timeout 20s --poll-interval 9m --vfs-cache-poll-interval 10m --daemon -vv &