From 3cb4c100c1a428629680d53d2e479c1e04e73d8d Mon Sep 17 00:00:00 2001 From: highghlow <132668972+highghlow@users.noreply.github.com> Date: Mon, 10 Jun 2024 15:52:32 +0300 Subject: [PATCH] Add Paperless-ngx (#1047) Co-authored-by: nmfretz --- paperless/data/data/.gitkeep | 0 paperless/data/media/.gitkeep | 0 paperless/data/pgdata/.gitkeep | 0 paperless/data/redisdata/.gitkeep | 0 paperless/docker-compose.yml | 61 +++++++++++++++++++++++++++++++ paperless/exports.sh | 32 ++++++++++++++++ paperless/umbrel-app.yml | 40 ++++++++++++++++++++ 7 files changed, 133 insertions(+) create mode 100644 paperless/data/data/.gitkeep create mode 100644 paperless/data/media/.gitkeep create mode 100644 paperless/data/pgdata/.gitkeep create mode 100644 paperless/data/redisdata/.gitkeep create mode 100644 paperless/docker-compose.yml create mode 100755 paperless/exports.sh create mode 100644 paperless/umbrel-app.yml diff --git a/paperless/data/data/.gitkeep b/paperless/data/data/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/paperless/data/media/.gitkeep b/paperless/data/media/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/paperless/data/pgdata/.gitkeep b/paperless/data/pgdata/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/paperless/data/redisdata/.gitkeep b/paperless/data/redisdata/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/paperless/docker-compose.yml b/paperless/docker-compose.yml new file mode 100644 index 0000000..1141411 --- /dev/null +++ b/paperless/docker-compose.yml @@ -0,0 +1,61 @@ +version: "3.7" + +services: + app_proxy: + environment: + APP_HOST: paperless_webserver_1 + APP_PORT: 8000 + + broker: + image: docker.io/library/redis:7@sha256:d6ecc832969a4827645a083da38345327b3447772fe907e7d4311c79b4e3a06e + restart: on-failure + volumes: + - ${APP_DATA_DIR}/data/redisdata:/data + + db: + image: docker.io/library/postgres:16 + restart: unless-stopped + volumes: + - ${APP_DATA_DIR}/data/pgdata:/var/lib/postgresql/data + environment: + POSTGRES_DB: paperless + POSTGRES_USER: paperless + POSTGRES_PASSWORD: paperless + + webserver: + image: ghcr.io/paperless-ngx/paperless-ngx:2.7.2@sha256:703c990a790dfd4d25fb56df3afec27b13cb0926a3818bf265edac9c71311647 + restart: on-failure + depends_on: + - db + - broker + - gotenberg + - tika + volumes: + - ${APP_DATA_DIR}/data/data:/usr/src/paperless/data + - ${APP_DATA_DIR}/data/media:/usr/src/paperless/media + # TODO: move these inside the paperless app data dir once umbrelOS supports navigating to it via the UI + - ${UMBREL_ROOT}/data/storage/paperless/export:/usr/src/paperless/export + - ${UMBREL_ROOT}/data/storage/paperless/consume:/usr/src/paperless/consume + environment: + PAPERLESS_REDIS: redis://paperless_broker_1:6379 + PAPERLESS_DBHOST: paperless_db_1 + PAPERLESS_TIKA_ENABLED: 1 + PAPERLESS_TIKA_GOTENBERG_ENDPOINT: http://paperless_gotenberg_1:3000 + PAPERLESS_TIKA_ENDPOINT: http://paperless_tika_1:9998 + PAPERLESS_ADMIN_USER: admin + PAPERLESS_ADMIN_PASSWORD: $APP_PASSWORD + + gotenberg: + image: docker.io/gotenberg/gotenberg:7.10@sha256:d03b8a04c6e6c5e568b38f57352266dee4674849b71818774025f8f48d869a9a + restart: on-failure + + # The gotenberg chromium route is used to convert .eml files. We do not + # want to allow external content like tracking pixels or even javascript. + command: + - "gotenberg" + - "--chromium-disable-javascript=true" + - "--chromium-allow-list=file:///tmp/.*" + + tika: + image: ghcr.io/paperless-ngx/tika:2.9.1-minimal@sha256:20db3df89eaeb1b271dd840888fe909b88b12f4b86ef641ec07a1d45d4c5168f + restart: on-failure diff --git a/paperless/exports.sh b/paperless/exports.sh new file mode 100755 index 0000000..58f9e56 --- /dev/null +++ b/paperless/exports.sh @@ -0,0 +1,32 @@ +# Ensure that Paperless consume and export directories are created with the correct permissions +UMBREL_DATA_DIR="${UMBREL_ROOT}/data" +UMBREL_DATA_STORAGE_DIR="${UMBREL_DATA_DIR}/storage" +UMBREL_DATA_STORAGE_PAPERLESS_DIR="${UMBREL_DATA_STORAGE_DIR}/paperless" +UMBREL_DATA_STORAGE_PAPERLESS_CONSUME_DIR="${UMBREL_DATA_STORAGE_PAPERLESS_DIR}/consume" +UMBREL_DATA_STORAGE_PAPERLESS_EXPORT_DIR="${UMBREL_DATA_STORAGE_PAPERLESS_DIR}/export" +DESIRED_OWNER="1000:1000" + +if [[ ! -d "${UMBREL_DATA_STORAGE_PAPERLESS_CONSUME_DIR}" ]]; then + mkdir -p "${UMBREL_DATA_STORAGE_PAPERLESS_CONSUME_DIR}" +fi + +if [[ ! -d "${UMBREL_DATA_STORAGE_PAPERLESS_EXPORT_DIR}" ]]; then + mkdir -p "${UMBREL_DATA_STORAGE_PAPERLESS_EXPORT_DIR}" +fi + +set_paperless_correct_permissions() { + local -r path="${1}" + + if [[ -d "${path}" ]]; then + owner=$(stat -c "%u:%g" "${path}") + + if [[ "${owner}" != "${DESIRED_OWNER}" ]]; then + chown "${DESIRED_OWNER}" "${path}" + fi + fi +} + +set_paperless_correct_permissions "${UMBREL_DATA_STORAGE_DIR}" +set_paperless_correct_permissions "${UMBREL_DATA_STORAGE_PAPERLESS_DIR}" +set_paperless_correct_permissions "${UMBREL_DATA_STORAGE_PAPERLESS_CONSUME_DIR}" +set_paperless_correct_permissions "${UMBREL_DATA_STORAGE_PAPERLESS_EXPORT_DIR}" diff --git a/paperless/umbrel-app.yml b/paperless/umbrel-app.yml new file mode 100644 index 0000000..0859c70 --- /dev/null +++ b/paperless/umbrel-app.yml @@ -0,0 +1,40 @@ +manifestVersion: 1 +id: paperless +category: files +name: Paperless-ngx +version: "2.7.2" +tagline: Transform your physical documents into a searchable online archive +description: >- + 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. + + - Organize and index your scanned documents with tags, correspondents, types, and more. + + - Your data is stored locally on your server and is never transmitted or shared in any way. + + - Performs OCR on your documents, adding searchable and selectable text, even to documents scanned with only images. + + - Utilizes the open-source Tesseract engine to recognize more than 100 languages. + + - Documents are saved as PDF/A format which is designed for long term storage, alongside the unaltered originals. + + - Uses machine-learning to automatically add tags, correspondents and document types to your documents. + + - Supports PDF documents, images, plain text files, Office documents (Word, Excel, Powerpoint, and LibreOffice equivalents)1 and more. + + - Paperless stores your documents plain on disk. Filenames and folders are managed by paperless and their format can be configured freely with different configurations assigned to different documents. +releaseNotes: "" +developer: Paperless-ngx Community +website: https://docs.paperless-ngx.com/ +dependencies: [] +repo: https://github.com/paperless-ngx/paperless-ngx +support: https://github.com/paperless-ngx/paperless-ngx/discussions +port: 2349 +gallery: + - 1.jpg + - 2.jpg + - 3.jpg +path: "" +defaultUsername: "admin" +deterministicPassword: true +submitter: highghlow +submission: https://github.com/getumbrel/umbrel-apps/pull/1047