-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.backend
More file actions
66 lines (53 loc) · 2.23 KB
/
Dockerfile.backend
File metadata and controls
66 lines (53 loc) · 2.23 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
# ============================================================
# ResearchOS Backend Dockerfile - FastAPI + Worker
# @author Color2333
# ============================================================
ARG BASE_REGISTRY=docker.io
FROM ${BASE_REGISTRY}/library/python:3.11-slim
WORKDIR /app
# 默认使用官方 apt 源;如需加速可在构建时传入 APT_MIRROR(如 mirrors.aliyun.com)
ARG APT_MIRROR=
RUN if [ -n "${APT_MIRROR}" ]; then \
sed -i "s/deb.debian.org/${APT_MIRROR}/g" /etc/apt/sources.list.d/debian.sources 2>/dev/null || true; \
sed -i "s/deb.debian.org/${APT_MIRROR}/g" /etc/apt/sources.list 2>/dev/null || true; \
fi
# 安装系统依赖
RUN apt-get update && apt-get install -y --no-install-recommends \
curl \
git \
poppler-utils \
sqlite3 \
&& rm -rf /var/lib/apt/lists/*
# 复制项目文件
COPY pyproject.toml constraints.txt ./
COPY packages/ packages/
COPY apps/ apps/
COPY scripts/ scripts/
COPY alembic.ini ./
COPY infra/migrations/ infra/migrations/
# 默认走官方 PyPI,避免部分镜像源返回损坏索引导致构建失败;
# 如需自定义镜像源,仍可在 docker build 时覆盖这些 build args。
ARG PIP_INDEX_URL=https://pypi.org/simple
ARG PIP_EXTRA_INDEX_URL=
ENV PIP_DEFAULT_TIMEOUT=180
ENV PIP_NO_CACHE_DIR=1
ENV PIP_DISABLE_PIP_VERSION_CHECK=1
ENV PIP_INDEX_URL=${PIP_INDEX_URL}
ENV PIP_EXTRA_INDEX_URL=${PIP_EXTRA_INDEX_URL}
RUN python -m pip install --no-cache-dir --retries 6 --no-build-isolation -c constraints.txt ".[llm,pdf]" \
&& python -m pip install --no-cache-dir --retries 6 -c constraints.txt \
umap-learn \
psutil \
supervisor
# 创建数据目录和日志目录
RUN mkdir -p /app/data/papers /app/data/briefs /app/logs
# 强制设置数据库路径(避免环境变量冲突问题)
ENV DATABASE_URL=sqlite:////app/data/researchos.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"]