Files
sanguo_vnpy_v2/docker/Dockerfile
T
claude_dev bf57aed17a retire(web): sanguo_web legacy 平行后端归档——用户拍板「代码保留归档,服务删」 [nas]
- git mv sanguo_web → _retired/sanguo_web/(git 历史保全+墓碑 README:
  归档原因/拍板记录/现役=sanguo_api)
- 退出启动面三处: promote.sh ALL_MODS 白名单(15→14 模块)+docker/Dockerfile:63
  COPY+docker/Dockerfile.nas:16 COPY——不可再被部署或启动为服务
- 背景(架构审计 P0-3): 硬编码 SECRET_KEY/admin123 默认口令/CORS 全开/可下
  真实订单/零测试/与 sanguo_api 路由冲突; 生产从未部署为服务, 纯误启动风险
  (README 旧「生产模式 uvicorn sanguo_web」指引已于 f6ca85e 勘误)
- three-env §3.1 模块清单+§12 矩阵行同步; session-guide §5 角色表前端行
  勘误(旧表把 sanguo_web 当前端模块推——实为 legacy 后端, 前端=frontend/)
- 零外部 import(runuweb/tests/packages 全 grep 实证), pytest testpaths=tests
  不受影响

Co-Authored-By: Claude Code <notify@anthropic.com>
2026-10-01 09:46:21 +08:00

86 lines
3.3 KiB
Docker
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Sanguo VeighNa Docker 镜像 - NAS 适配版
# 使用 Python 3.10(Synology NAS 已有镜像)
# 单阶段构建,简化部署流程
FROM python:3.10-slim
# 设置环境变量
ENV TZ=Asia/Shanghai \
DEBIAN_FRONTEND=noninteractive \
PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
VNPY_LOG_LEVEL=INFO \
TA_LIBRARY_PATH=/usr/local/lib \
TA_INCLUDE_PATH=/usr/local/include
# 换国内 debian 镜像(清华,trixie deb822 格式;原 deb.debian.org 国内不稳 apt 反复重试)
RUN { sed -i 's|deb.debian.org|mirrors.tuna.tsinghua.edu.cn|g; s|security.debian.org|mirrors.tuna.tsinghua.edu.cn|g' /etc/apt/sources.list.d/debian.sources 2>/dev/null || sed -i 's|deb.debian.org|mirrors.tuna.tsinghua.edu.cn|g; s|security.debian.org|mirrors.tuna.tsinghua.edu.cn|g' /etc/apt/sources.list 2>/dev/null; }
# 安装运行时和编译依赖
RUN apt-get update && apt-get install -y --no-install-recommends \
curl \
build-essential \
wget \
gcc \
g++ \
make \
libc6-dev \
&& rm -rf /var/lib/apt/lists/*
# 下载并编译 TA-Lib
RUN wget -q http://prdownloads.sourceforge.net/ta-lib/ta-lib-0.4.0-src.tar.gz \
&& tar -xzf ta-lib-0.4.0-src.tar.gz \
&& cd ta-lib \
&& ./configure --prefix=/usr \
&& make \
&& make install \
&& cd .. \
&& rm -rf ta-lib ta-lib-0.4.0-src.tar.gz
# 更新 ldconfig
RUN ldconfig
# 设置工作目录
WORKDIR /app
# 创建数据目录
RUN mkdir -p /app/data /app/logs /app/config /app/temp
# 复制 requirements 并安装依赖
COPY requirements-docker.txt .
RUN pip install --no-cache-dir --upgrade pip -i https://pypi.tuna.tsinghua.edu.cn/simple && \
pip install --no-cache-dir -r requirements-docker.txt -i https://pypi.tuna.tsinghua.edu.cn/simple && \
pip install --no-cache-dir --no-deps empyrical-reloaded==0.5.12 -i https://pypi.tuna.tsinghua.edu.cn/simple && \
pip install --no-cache-dir peewee==3.17.3 -i https://pypi.tuna.tsinghua.edu.cn/simple
# ↑ 两个单独安装步骤均为解依赖死锁(2026-08-15 一/二次构建实证):
# ① empyrical-reloaded --no-deps:其元数据伪依赖 peewee<3.17.4 与 vnpy_sqlite 的
# >=3.17.9 互斥,合入 requirements 单次解析必 ResolutionImpossible;包体零引用
# peewee(实测),真依赖 bottleneck/numpy/pandas/scipy 已在主文件钉版。
# ② peewee==3.17.3 显式降级对齐 VPS 生产实证版(主清单 resolver 会按 vnpy_sqlite
# 声明装 ≥3.17.9,单装只校验自身依赖可落 3.17.3;vnpy_sqlite 实证兼容)。
# 复制应用代码(包含所有 sanguo 模块)
COPY vnpy_v4.4.0/vnpy/ /app/vnpy/
COPY sanguo_trader/ /app/sanguo_trader/
COPY sanguo_research/ /app/sanguo_research/
COPY sanguo_data/ /app/sanguo_data/
COPY sanguo_common/ /app/sanguo_common/
# Python 路径(spawn 子进程继承 env 不继承 sys.path;放 COPY 后让 apt/TA-Lib/pip 层缓存命中,
# 避免 sourceforge wget 卡——ENV 在前会导致其后所有层 cache miss 触发 TA-Lib 重编译)
ENV PYTHONPATH=/app:/app/vnpy_v4.4.0
# 复制启动脚本
COPY entrypoint.sh /app/
RUN chmod +x /app/entrypoint.sh
# 暴露端口
EXPOSE 8000 8080
# 健康检查
HEALTHCHECK --interval=30s --timeout=10s --start-period=30s --retries=3 \
CMD curl -f http://localhost:8000/health || exit 1
# 启动命令
ENTRYPOINT ["/app/entrypoint.sh"]