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.
This commit is contained in:
MickLesk committed 2026-11-11 21:03:05 +01:00
1 parent fb58720888
commit 5b1a07b7c1
2 files changed
+47 -95

No files matched your search

+38 -22
View File
@@ -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"
# 3.x ran a second Python service and read data/.env as its environment;
# 4.x migrates that file itself and locks every setting passed as a variable.
if [[ -f /etc/systemd/system/paperless-rag.service ]]; then
msg_info "Migrating services to Paperless-AI 4"
systemctl disable -q paperless-rag
rm -f /etc/systemd/system/paperless-rag.service
cat <<EOF >/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!"
+9 -73
View File
@@ -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 <<EOF
[global]
break-system-packages = true
EOF
msg_ok "Installed Python3"
NODE_VERSION="22" setup_nodejs
fetch_and_deploy_gh_release "paperless-ai" "clusterzx/paperless-ai" "tarball"
msg_info "Setup Paperless-AI"
cd /opt/paperless-ai
$STD python3 -m venv /opt/paperless-ai/venv
source /opt/paperless-ai/venv/bin/activate
# TMPDIR to use container disk instead of tmpfs for large pip downloads (https://github.com/community-scripts/ProxmoxVE/issues/10338)
export TMPDIR=/opt/paperless-ai/tmp
mkdir -p "$TMPDIR"
$STD pip install --upgrade pip
$STD pip install --no-cache-dir -r requirements.txt
rm -rf "$TMPDIR"
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
mkdir -p /opt/paperless-ai/data
cat <<EOF >/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 <<EOF >/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 <<EOF >/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"