From b1597ac3d15e989ca460cc3129bc208baca9176f Mon Sep 17 00:00:00 2001 From: "CanbiZ (MickLesk)" <47820557+MickLesk@users.noreply.github.com> Date: Wed, 11 Nov 2026 23:53:08 +0100 Subject: [PATCH] Paperless-AI: install and update to 4.0 (#18620) * Paperless-AI: install and update to 4.0 4.0 is a rewrite as a single Node.js process. requirements.txt is gone, so every install since its release on 2026-11-10 failed at pip, and an update would have failed the same way. Install and update now build it the way upstream's image does. An update from 3.x removes the Python RAG service and rewrites the unit without data/.env as its environment: 4.0 migrates that file on first start and treats any setting passed as a variable as locked. * Paperless-AI: migrate pre-RAG 3.x units too, drop comments --- ct/paperless-ai.sh | 66 ++++++++++++++++---------- install/paperless-ai-install.sh | 82 ++++----------------------------- 2 files changed, 50 insertions(+), 98 deletions(-) diff --git a/ct/paperless-ai.sh b/ct/paperless-ai.sh index e61aecd4f..1b67e9563 100644 --- a/ct/paperless-ai.sh +++ b/ct/paperless-ai.sh @@ -32,36 +32,52 @@ function update_script() { if check_for_gh_release "paperless-ai" "clusterzx/paperless-ai"; then msg_info "Stopping Service" - systemctl stop paperless-ai paperless-rag + systemctl stop paperless-ai + if [[ -f /etc/systemd/system/paperless-rag.service ]]; then + systemctl stop paperless-rag + fi msg_ok "Stopped Service" - msg_info "Backing up data" - cp -r /opt/paperless-ai/data /opt/paperless-ai-data-backup - msg_ok "Backed up data" - - fetch_and_deploy_gh_release "paperless-ai" "clusterzx/paperless-ai" "tarball" - - msg_info "Restoring data" - cp -r /opt/paperless-ai-data-backup/* /opt/paperless-ai/data/ - rm -rf /opt/paperless-ai-data-backup - msg_ok "Restored data" + NODE_VERSION="22" setup_nodejs + CLEAN_INSTALL=1 CLEAN_INSTALL_KEEP="data" fetch_and_deploy_gh_release "paperless-ai" "clusterzx/paperless-ai" "tarball" msg_info "Updating Paperless-AI" cd /opt/paperless-ai - if [[ ! -d /opt/paperless-ai/venv ]]; then - msg_info "Recreating Python venv" - $STD python3 -m venv /opt/paperless-ai/venv - fi - source /opt/paperless-ai/venv/bin/activate - $STD pip install --upgrade pip - $STD pip install --no-cache-dir -r requirements.txt - mkdir -p data/chromadb - $STD npm ci --only=production + export ONNXRUNTIME_NODE_INSTALL=skip PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 + $STD npm ci --ignore-scripts --no-audit --no-fund + $STD npm run build + $STD npm prune --omit=dev --ignore-scripts --no-audit --no-fund msg_ok "Updated Paperless-AI" + if ! grep -q "dist/server/index.js" /etc/systemd/system/paperless-ai.service; then + msg_info "Migrating services to Paperless-AI 4" + if [[ -f /etc/systemd/system/paperless-rag.service ]]; then + systemctl disable -q paperless-rag + rm -f /etc/systemd/system/paperless-rag.service + fi + cat </etc/systemd/system/paperless-ai.service +[Unit] +Description=PaperlessAI Service +After=network.target + +[Service] +WorkingDirectory=/opt/paperless-ai +Environment="NODE_ENV=production" +Environment="PAPERLESS_AI_PORT=3000" +Environment="PAPERLESS_AI_DATA_DIR=/opt/paperless-ai/data" +Environment="HF_HUB_DISABLE_TELEMETRY=1" +ExecStart=/usr/bin/node dist/server/index.js +Restart=always + +[Install] +WantedBy=multi-user.target +EOF + systemctl daemon-reload + msg_ok "Migrated services to Paperless-AI 4" + msg_warn "Settings and history from 3.x are migrated on first start. If this instance was reachable from the internet, read 'Upgrading from 3.x' in the upstream README first." + fi + msg_info "Starting Service" - systemctl start paperless-rag - sleep 3 systemctl start paperless-ai msg_ok "Started Service" msg_ok "Updated successfully!" @@ -73,7 +89,7 @@ start build_container description -msg_ok "Completed successfully!\n" +msg_ok "Completed Successfully!\n" echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}" -echo -e "${INFO}${YW}Access it using the following URL:${CL}" -echo -e "${GATEWAY}${BGN}http://${IP}:3000${CL}" +echo -e "${INFO}${YW} Access it using the following URL:${CL}" +echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:3000${CL}" diff --git a/install/paperless-ai-install.sh b/install/paperless-ai-install.sh index f536d50bc..a14bd3532 100644 --- a/install/paperless-ai-install.sh +++ b/install/paperless-ai-install.sh @@ -13,100 +13,36 @@ setting_up_container network_check update_os -msg_info "Installing Dependencies" -$STD apt install -y \ - build-essential -msg_ok "Installed Dependencies" - -msg_info "Installing Python3" -$STD apt install -y \ - python3-pip \ - python3-dev \ - python3-venv -mkdir -p ~/.config/pip -cat >~/.config/pip/pip.conf </opt/paperless-ai/data/.env -PAPERLESS_API_URL= -PAPERLESS_API_TOKEN= -PAPERLESS_USERNAME= -AI_PROVIDER=openai -OPENAI_API_KEY= -OPENAI_MODEL=gpt-4o-mini -OLLAMA_API_URL= -OLLAMA_MODEL= -SCAN_INTERVAL=*/10 * * * * -SYSTEM_PROMPT="" -PROCESS_PREDEFINED_DOCUMENTS=no -TAGS= -ADD_AI_PROCESSED_TAG=no -AI_PROCESSED_TAG_NAME=ki-gen -USE_PROMPT_TAGS=no -PROMPT_TAGS= -USE_EXISTING_DATA=no -API_KEY= -CUSTOM_API_KEY= -CUSTOM_BASE_URL= -CUSTOM_MODEL= -RAG_SERVICE_URL=http://localhost:8000 -RAG_SERVICE_ENABLED=true -EOF msg_ok "Setup Paperless-AI" msg_info "Creating Service" cat </etc/systemd/system/paperless-ai.service [Unit] Description=PaperlessAI Service -After=network.target paperless-rag.service -Requires=paperless-rag.service - -[Service] -WorkingDirectory=/opt/paperless-ai -Environment="NODE_ENV=production" -EnvironmentFile=/opt/paperless-ai/data/.env -ExecStart=/usr/bin/node server.js -Restart=always - -[Install] -WantedBy=multi-user.target -EOF - -cat </etc/systemd/system/paperless-rag.service -[Unit] -Description=PaperlessAI-RAG Service After=network.target [Service] WorkingDirectory=/opt/paperless-ai -EnvironmentFile=/opt/paperless-ai/data/.env -ExecStart=/opt/paperless-ai/venv/bin/python3 main.py --host 0.0.0.0 --port 8000 --initialize +Environment="NODE_ENV=production" +Environment="PAPERLESS_AI_PORT=3000" +Environment="PAPERLESS_AI_DATA_DIR=/opt/paperless-ai/data" +Environment="HF_HUB_DISABLE_TELEMETRY=1" +ExecStart=/usr/bin/node dist/server/index.js Restart=always [Install] WantedBy=multi-user.target EOF -systemctl enable -q --now paperless-rag -sleep 5 systemctl enable -q --now paperless-ai msg_ok "Created Service"