feat(ocr): 集成 PaddleOCR 服务并优化 OCR 系统

- 新增 PaddleOCR 本地高精度 OCR 服务支持,包括 Dockerfile、API 服务和 provider 实现
- 在 docker-compose 中集成 RapidOCR 和 PaddleOCR 服务,并配置健康检查
- 优化后端 API 路由前缀,移除 `/api` 以简化代理配置
- 更新 Nginx 配置以正确传递请求头和代理 WebSocket 连接
- 在前端设置页面添加 PaddleOCR 和 RapidOCR 的测试与配置选项
- 修复后端 Dockerfile 以支持 Python 原生模块构建
- 更新 OCR 设置指南,反映当前服务状态和部署方式
- 添加上传文件调试日志和权限设置
This commit is contained in:
congsh
2026-02-27 18:43:07 +08:00
parent 764c6a8c0c
commit 9a301cc434
17 changed files with 628 additions and 85 deletions

View File

@@ -26,12 +26,18 @@ services:
DEEPSEEK_API_KEY: ${DEEPSEEK_API_KEY:-}
UPLOAD_MAX_SIZE: ${UPLOAD_MAX_SIZE:-10485760}
UPLOAD_ALLOWED_TYPES: ${UPLOAD_ALLOWED_TYPES:-image/jpeg,image/png,image/webp}
# OCR Services URLs
RAPIDOCR_API_URL: ${RAPIDOCR_API_URL:-http://rapidocr:9004}
PADDLEOCR_API_URL: ${PADDLEOCR_API_URL:-http://paddleocr:8866}
volumes:
# Persist database and uploads
- backend-data:/app/data
- backend-uploads:/app/uploads
networks:
- picanalysis-network
depends_on:
- rapidocr
- paddleocr
healthcheck:
test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:13057/api/health"]
interval: 30s
@@ -39,6 +45,45 @@ services:
retries: 3
start_period: 40s
# ========================
# RapidOCR Service (本地快速 OCR)
# ========================
rapidocr:
image: volador/rapidocr:latest
container_name: picanalysis-rapidocr
restart: unless-stopped
ports:
- "13058:9004"
networks:
- picanalysis-network
healthcheck:
test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:9004"]
interval: 30s
timeout: 10s
retries: 3
start_period: 20s
# ========================
# PaddleOCR Service (本地高精度 OCR - 使用官方预构建镜像)
# ========================
paddleocr:
image: 987846/paddleocr:latest
container_name: picanalysis-paddleocr
restart: unless-stopped
ports:
- "13059:8866"
environment:
# 修复 protobuf 兼容性问题
PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION: python
networks:
- picanalysis-network
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8866/"]
interval: 30s
timeout: 10s
retries: 3
start_period: 60s
# ========================
# Frontend Service
# ========================