-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathDockerfile
More file actions
53 lines (43 loc) · 1.53 KB
/
Copy pathDockerfile
File metadata and controls
53 lines (43 loc) · 1.53 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
# ============================================
# 后端 (FastAPI) Dockerfile - 单阶段精简版
# ============================================
FROM python:3.11-slim AS backend
WORKDIR /app
# 环境变量
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
PIP_NO_CACHE_DIR=1 \
PIP_DISABLE_PIP_VERSION_CHECK=1
# 更换为国内镜像源(阿里云)
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 \
gcc \
g++ \
git \
curl \
&& rm -rf /var/lib/apt/lists/*
# 复制依赖文件
COPY requirements.txt pyproject.toml setup.py ./
# 安装 Python 依赖
RUN pip install --upgrade pip -i https://pypi.tuna.tsinghua.edu.cn/simple && \
pip install -U -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple && \
pip install "uvicorn[standard]" "websockets" -i https://pypi.tuna.tsinghua.edu.cn/simple
# 复制项目文件
COPY tradingagents/ ./tradingagents/
COPY web/backend/ ./web/backend/
COPY web/__init__.py ./web/
COPY cli/ ./cli/
COPY main.py ./
COPY .env.example ./.env
# 安装项目
RUN pip install -e . -i https://pypi.tuna.tsinghua.edu.cn/simple
# 创建必要的目录
RUN mkdir -p eval_results assets web/static web/templates
# 时区改成上海
RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
# 暴露端口
EXPOSE 8000
# 默认启动后端服务
CMD ["python", "web/backend/app.py"]