-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathDockerfile.backend
More file actions
53 lines (41 loc) · 1.68 KB
/
Dockerfile.backend
File metadata and controls
53 lines (41 loc) · 1.68 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
# ============================================================
# 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 \
&& rm -rf /var/lib/apt/lists/*
# 复制项目文件
COPY pyproject.toml ./
COPY packages/ packages/
COPY apps/ apps/
COPY scripts/ scripts/
COPY alembic.ini ./
COPY infra/migrations/ infra/migrations/
# 使用国内 pip 镜像源安装依赖
RUN pip install --cache-dir=/.pip-cache ".[llm,pdf]" \
-i https://mirrors.aliyun.com/pypi/simple/ \
&& pip install --cache-dir=/.pip-cache \
umap-learn \
psutil \
supervisor \
-i https://mirrors.aliyun.com/pypi/simple/
# 创建数据目录和日志目录
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"]