Paperless-ngx 是一种文档管理系统,能将纸质文档转化为可搜索的在线档案,这样就可以减少纸质文档的使用量。本文记录了部署过程。

项目地址:paperless-ngx/paperless-ngx

docker-compose方式部署

项目/docker/compose目录下有各种模板,分别为使用不同数据库,不同文档支持。
这里要用的三个文件:.env,docker-compose.env,docker-compose.sqlite-tika.yml。
使用sqlite数据库,tika是支持doc和docx的插件。使用不带tika字样的compose时,系统不支持word文档的上传和识别。
把这三个文件放到一个目录下,
修改docker-compose.env中的时区为Asia/Shanghai,按照文件中

1
2
3
# Required. A unique secret key for session tokens and signing.
# Generate with: python3 -c "import secrets; print(secrets.token_urlsafe(64))"
PAPERLESS_SECRET_KEY=change-me

在cmd下执行
python -c "import secrets; print(secrets.token_urlsafe(64))"
得到一个字符串string。
在.env文件中加上PAPERLESS_SECRET_KEY=string
注:在docker-compose.env中设置的不起作用,需放入.env中。
docker-compose.sqlite-tika.yml改名为docker-compose.yml,在其中添加:
PAPERLESS_SECRET_KEY: ${PAPERLESS_SECRET_KEY},完整内容如下

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
services:
broker:
image: docker.io/valkey/valkey:9-alpine
restart: unless-stopped
volumes:
- redisdata:/data
webserver:
image: ghcr.io/paperless-ngx/paperless-ngx:latest
restart: unless-stopped
depends_on:
- broker
- gotenberg
- tika
ports:
- "8000:8000"
volumes:
- data:/usr/src/paperless/data
- media:/usr/src/paperless/media
- ./export:/usr/src/paperless/export
- ./consume:/usr/src/paperless/consume
env_file: docker-compose.env
environment:
PAPERLESS_REDIS: redis://broker:6379
PAPERLESS_DBENGINE: sqlite
PAPERLESS_SECRET_KEY: ${PAPERLESS_SECRET_KEY}
PAPERLESS_TIKA_ENABLED: 1
PAPERLESS_TIKA_GOTENBERG_ENDPOINT: http://gotenberg:3000
PAPERLESS_TIKA_ENDPOINT: http://tika:9998
gotenberg:
image: docker.io/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.
command:
- "gotenberg"
- "--chromium-disable-javascript=true"
- "--chromium-allow-list=file:///tmp/.*"
tika:
image: docker.io/apache/tika:latest
restart: unless-stopped
volumes:
data:
media:
redisdata:

在当前目录下执行docker compose up -d,等待容器建立完成。

使用

从ip:8000进入,首次进入要设置管理员账户和密码。


上传文档的时候,会自动识别文档内容,图片ocr,之后可用关键字搜索。
Paperless-ngx 容器内的 OCR 引擎(Tesseract),缺少简体中文(chi_sim)的语言数据包,要在容器内安装 tesseract-ocr-chi-sim 语言包。
进入容器
paperless-webserver-1执行apt update && apt install -y tesseract-ocr-chi-sim,退出容器,并重启 Paperless 服务使配置生效。

主机性能不好就不要设置ocr相关,会卡死。j1900性能不足以完成ocr任务。Tesseract对印刷体识别尚可,手写体识别完全不行,可接入本地AI大模型。