-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
61 lines (51 loc) · 1.62 KB
/
Copy pathDockerfile
File metadata and controls
61 lines (51 loc) · 1.62 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
# ===== 阶段1: 前端构建 =====
FROM node:20-alpine AS frontend-builder
WORKDIR /app/frontend
COPY frontend/package.json frontend/package-lock.json* ./
RUN npm install
COPY frontend/ .
RUN npm run build
# ===== 阶段2: 后端运行时 =====
FROM python:3.11-slim
WORKDIR /app
# 安装系统依赖
RUN apt-get update && apt-get install -y --no-install-recommends \
gcc \
&& rm -rf /var/lib/apt/lists/*
# 安装 Python 依赖
COPY pyproject.toml ./
RUN pip install --no-cache-dir \
fastapi>=0.111.0 \
"uvicorn[standard]>=0.30.0" \
"pydantic>=2.7.0" \
"pydantic-settings>=2.3.0" \
"sqlalchemy>=2.0.30" \
"pyyaml>=6.0" \
"regex>=2024.5.15" \
"httpx>=0.27.0" \
"openai>=1.30.0" \
"python-multipart>=0.0.9" \
"python-dotenv>=1.0.0" \
"rich>=13.7.0"
# 按需安装的可选依赖(tree-sitter / chromadb / mcp)
RUN pip install --no-cache-dir \
"tree-sitter>=0.22.0" \
"tree-sitter-languages>=1.10.0" \
"chromadb>=0.5.0" \
"mcp>=1.0.0" \
|| echo "部分可选依赖安装失败,将降级运行"
# 复制后端代码
COPY linway/ ./linway/
COPY rules/ ./rules/
# 复制前端构建产物
COPY --from=frontend-builder /app/frontend/dist ./frontend/dist
# 环境变量默认值
ENV DATABASE_URL=sqlite:///./linway.db \
DEBUG=false \
CORS_ORIGINS=http://localhost:5173,http://localhost:3000 \
PYTHONUNBUFFERED=1
EXPOSE 8000
# 健康检查
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
CMD python -c "import urllib.request; urllib.request.urlopen('http://localhost:8000/api/health')" || exit 1
CMD ["python", "-m", "linway.main"]