Paper_Trading / Dockerfile
superxuu
fix: Update Dockerfile with data directory and explicit path
73cb997
# ==========================================
# Stage 1: Build Frontend (Next.js)
# ==========================================
FROM node:20-alpine AS frontend-builder
WORKDIR /app-frontend
# 安装依赖
COPY ./frontend/package*.json ./
RUN npm install
# 构建静态资源
COPY ./frontend .
ENV NEXT_TELEMETRY_DISABLED=1
# 确保 next 可以在 alpine 中运行
RUN npm run build
# ==========================================
# Stage 2: Build Backend & Runtime
# ==========================================
FROM python:3.11-slim
WORKDIR /app
# 创建数据目录
RUN mkdir -p /app/data && chmod 777 /app/data
# 安装系统依赖 (Git用于HF SDK)
RUN apt-get update && apt-get install -y git && rm -rf /var/lib/apt/lists/*
# 安装 Python 依赖
COPY ./backend/requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# 复制后端代码
COPY ./backend .
# 从 Stage 1 复制前端静态文件到 FastAPI 的 static 目录
COPY --from=frontend-builder /app-frontend/out /app/static
# 环境变量设置
ENV HF_HOME=/tmp/.huggingface
ENV DUCKDB_PATH=/app/data/stock_data.duckdb
ENV PORT=7860
# 暴露端口
EXPOSE 7860
# 启动命令
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"]