mirror of
https://github.com/ZhuLinsen/daily_stock_analysis
synced 2026-09-20 10:53:33 +08:00
* feat!: replace legacy WebUI with unified FastAPI architecture #major - Remove legacy WebUI (web/ package based on ThreadingHTTPServer) - Unify CLI commands: --webui now seamlessly launches the new FastAPI service - Migrate task service from web/services.py to src/services/task_service.py - Update documentation to reflect the new simplified usage * refactor(service): support parameterized query source in TaskService
69 lines
1.6 KiB
Docker
69 lines
1.6 KiB
Docker
# ===================================
|
||
# A股自选股智能分析系统 - Docker 镜像
|
||
# ===================================
|
||
# 多阶段构建:前端打包 + 后端运行
|
||
|
||
FROM node:20-slim AS web-builder
|
||
|
||
WORKDIR /app/apps/dsa-web
|
||
|
||
COPY apps/dsa-web/package.json apps/dsa-web/package-lock.json ./
|
||
RUN npm ci
|
||
|
||
COPY apps/dsa-web/ ./
|
||
RUN npm run build
|
||
|
||
FROM python:3.11-slim
|
||
|
||
# 设置工作目录
|
||
WORKDIR /app
|
||
|
||
# 设置时区为上海
|
||
ENV TZ=Asia/Shanghai
|
||
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
|
||
|
||
# 安装系统依赖
|
||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||
gcc \
|
||
curl \
|
||
&& rm -rf /var/lib/apt/lists/*
|
||
|
||
# 复制依赖文件
|
||
COPY requirements.txt .
|
||
|
||
# 安装 Python 依赖
|
||
RUN pip install --no-cache-dir -r requirements.txt
|
||
|
||
# 复制应用代码
|
||
COPY *.py ./
|
||
COPY api/ ./api/
|
||
COPY data_provider/ ./data_provider/
|
||
COPY bot/ ./bot/
|
||
COPY src/ ./src/
|
||
COPY --from=web-builder /app/static ./static/
|
||
|
||
# 创建数据目录
|
||
RUN mkdir -p /app/data /app/logs /app/reports
|
||
|
||
# 设置环境变量默认值
|
||
ENV PYTHONUNBUFFERED=1
|
||
ENV LOG_DIR=/app/logs
|
||
ENV DATABASE_PATH=/app/data/stock_analysis.db
|
||
# API 服务
|
||
ENV API_HOST=0.0.0.0
|
||
ENV API_PORT=8000
|
||
|
||
# 暴露 API 端口
|
||
EXPOSE 8000
|
||
|
||
# 数据卷(持久化数据)
|
||
VOLUME ["/app/data", "/app/logs", "/app/reports"]
|
||
|
||
# 健康检查(FastAPI 模式)
|
||
HEALTHCHECK --interval=30s --timeout=10s --start-period=10s --retries=3 \
|
||
CMD curl -f http://localhost:8000/api/health || curl -f http://localhost:8000/health \
|
||
|| python -c "import sys; sys.exit(0)"
|
||
|
||
# 默认命令(可被覆盖)
|
||
CMD ["python", "main.py", "--schedule"]
|