Spaces:
Build error
Build error
| # 使用多阶段构建以减少最终镜像大小 | |
| FROM node:18-alpine as frontend-builder | |
| # 安装git | |
| RUN apk add --no-cache git | |
| # 克隆代码库 | |
| RUN git clone https://github.com/lanzhihong6/stock-scanner.git /app | |
| # 设置前端工作目录 | |
| WORKDIR /app/frontend | |
| # 安装依赖并构建前端 | |
| RUN npm ci && npm run build | |
| # 后端阶段 | |
| FROM python:3.10-slim | |
| # 设置工作目录 | |
| WORKDIR /app | |
| # 安装git和运行时依赖 | |
| RUN apt-get update && apt-get install -y \ | |
| git \ | |
| libgl1-mesa-glx \ | |
| ca-certificates \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # 克隆代码库 | |
| RUN git clone https://github.com/lanzhihong6/stock-scanner.git /app && \ | |
| chmod -R 777 /app && \ | |
| chmod +x /app/web_server.py | |
| # 安装Python依赖 | |
| RUN pip install --no-cache-dir -r requirements.txt | |
| # 从前端构建阶段复制生成的静态文件到后端的前端目录 | |
| COPY --from=frontend-builder /app/frontend/dist /app/frontend/dist | |
| # 暴露端口 | |
| EXPOSE 8888 | |
| # 启动命令 | |
| CMD ["python", "web_server.py"] |