Repository navigation
Expand file tree
/
Copy pathDockerfile.backend
More file actions
74 lines (60 loc) · 2.82 KB
/
Copy pathDockerfile.backend
File metadata and controls
74 lines (60 loc) · 2.82 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# ============================================================
# PaperMind Backend Dockerfile - FastAPI + Worker
# @author Color2333
# ============================================================
FROM python:3.11-slim
WORKDIR /app
# 使用国内镜像源(阿里云)加速 apt 更新
RUN sed -i 's/deb.debian.org/mirrors.aliyun.com/g' /etc/apt/sources.list.d/debian.sources 2>/dev/null || \
sed -i 's/deb.debian.org/mirrors.aliyun.com/g' /etc/apt/sources.list 2>/dev/null || true
# 安装系统依赖
RUN apt-get update && apt-get install -y --no-install-recommends \
curl \
sqlite3 \
xz-utils \
&& rm -rf /var/lib/apt/lists/*
# Node 22(pm 依赖用 fs.globSync 等 Node≥22 API;Debian apt 的 18 不够)。
# 走 npmmirror 二进制镜像(大陆可达)
RUN curl -fsSL --retry 5 --retry-delay 3 --retry-all-errors \
-o /tmp/node.tar.xz \
https://registry.npmmirror.com/-/binary/node/v22.23.3/node-v22.23.3-linux-x64.tar.xz \
&& tar -xJf /tmp/node.tar.xz --strip-components=1 -C /usr/local \
&& rm /tmp/node.tar.xz \
&& node --version
# 复制项目文件
COPY pyproject.toml ./
COPY packages/ packages/
COPY apps/ apps/
COPY scripts/ scripts/
COPY alembic.ini ./
COPY infra/migrations/ infra/migrations/
# 使用腾讯云 pip 镜像源(阿里云镜像下载大文件不稳,腾讯云源稳定且 ECS 内网快)
# graph extra 含 numpy/scikit-learn/umap-learn(similarity.py 降维散点图用)
RUN pip install --cache-dir=/.pip-cache ".[llm,pdf,graph]" \
-i https://mirrors.cloud.tencent.com/pypi/simple \
--timeout 60 --retries 5 \
&& pip install --cache-dir=/.pip-cache \
psutil \
supervisor \
-i https://mirrors.cloud.tencent.com/pypi/simple \
--timeout 60 --retries 5
# Pi agent 桥:Node 版 pm(webchat spawn `pm -p --json` 的执行体)。
# pip 装的 apps/cli Python pm 占了 /usr/local/bin/pm——Node 版符号链接必须覆盖它
# (host.py spawn `pm -p --json`,Python pm 不认识 → exit 2,生产实证)。
COPY pm_agent/ /opt/pm-agent/
RUN cd /opt/pm-agent \
&& npm install --omit=dev --registry=https://registry.npmmirror.com \
&& ln -sf /opt/pm-agent/bin/pm.js /usr/local/bin/pm \
&& pm --version | grep -q papermind/cli
# 创建数据目录和日志目录
RUN mkdir -p /app/data/papers /app/data/briefs /app/logs
# 强制设置数据库路径(避免环境变量冲突问题)
ENV DATABASE_URL=sqlite:////app/data/papermind.db
ENV PYTHONUNBUFFERED=1
# 初始化数据库(如果不存在)
RUN python scripts/local_bootstrap.py || true
EXPOSE 8000
HEALTHCHECK --interval=30s --timeout=5s --start-period=40s --retries=3 \
CMD curl -sf http://localhost:8000/health || exit 1
# 默认命令(可以被 docker-compose 覆盖)
CMD ["python", "-m", "uvicorn", "apps.api.main:app", "--host", "0.0.0.0", "--port", "8000"]