init: RAG 知识库服务初始提交

- 后端 API(Flask + Gunicorn)
- RAG 引擎(混合检索 + 云端 Reranker + 引用溯源)
- 文档解析(MinerU + 多格式支持)
- Docker 生产部署配置
- 排除前端项目、敏感配置、模型文件
This commit is contained in:
lacerate551
2026-06-04 17:35:27 +08:00
commit 100d1a06eb
158 changed files with 64534 additions and 0 deletions

62
deploy/Dockerfile.prod Normal file
View File

@@ -0,0 +1,62 @@
# Dockerfile.prod - 生产环境优化版
# ================================
# 特点CPU-only、精简依赖、最小化镜像
FROM python:3.10-slim
WORKDIR /app
# 使用阿里云镜像源
RUN sed -i 's/deb.debian.org/mirrors.aliyun.com/g' /etc/apt/sources.list.d/debian.sources \
&& sed -i 's/security.debian.org/mirrors.aliyun.com/g' /etc/apt/sources.list.d/debian.sources
# 系统依赖(精简版)
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
poppler-utils \
libmagic1 \
curl \
&& rm -rf /var/lib/apt/lists/*
# ==================== PyTorchCPU 模式) ====================
# 先从阿里云安装 PyTorch 依赖(避免从 PyPI 下载超时)
RUN pip install --no-cache-dir networkx sympy mpmath typing-extensions \
-i https://mirrors.aliyun.com/pypi/simple/
# 再从 PyTorch 官方源下载 CPU-only 版本(约 200MB跳过依赖解析
RUN pip install --no-cache-dir --no-deps torch --index-url https://download.pytorch.org/whl/cpu
# 设置 PyTorch 使用 CPU 模式
ENV CUDA_VISIBLE_DEVICES=""
# ==================== Python 依赖 ====================
COPY requirements-prod.txt .
RUN pip install --no-cache-dir -r requirements-prod.txt \
-i https://mirrors.aliyun.com/pypi/simple/
# ==================== 应用代码 ====================
COPY . .
# ==================== MinerU 配置 ====================
# 生产环境使用本地模型
RUN mkdir -p /root && echo '{\n\
"models-dir": {\n\
"pipeline": "/app/models/mineru/pipeline",\n\
"vlm": "/app/models/mineru/vlm"\n\
},\n\
"config_version": "1.3.1"\n\
}' > /root/mineru.json
ENV MINERU_MODEL_SOURCE=local
ENV MINERU_TOOLS_CONFIG_JSON=/root/mineru.json
# ==================== 数据目录 ====================
RUN mkdir -p knowledge/vector_store documents models .data
# ==================== 环境变量 ====================
ENV APP_ENV=prod
ENV PYTHONUNBUFFERED=1
EXPOSE 5001
# 生产模式启动
CMD ["gunicorn", "-c", "deploy/gunicorn.conf.py", "deploy.wsgi:app"]