- 基础镜像中添加多款中文字体,支持中文显示 - 主镜像安装中文字体并设置上海时区环境变量 - Dockerfile中创建日志目录并修改默认启动命令为定时调用调度器脚本 - 构建脚本支持动态镜像名,自动构建基础镜像,完善运行容器示例 - docker-compose修改为仅启动调度器服务,挂载相关配置、密钥、数据和日志目录 - 依赖更新,丰富金融数据、技术分析、绘图、机器学习及环境变量支持库 - 调度脚本参数调整,支持立即运行并退出及非后台模式运行切换 - 报告绘图中优先使用基础镜像预装的中文字体配置,提高字体兼容性和显示效果
83 lines
2.0 KiB
Plaintext
83 lines
2.0 KiB
Plaintext
FROM python:3.12-slim
|
|
|
|
# 设置工作目录
|
|
WORKDIR /app
|
|
|
|
# 安装系统依赖
|
|
RUN apt-get update && apt-get install -y \
|
|
wget \
|
|
gnupg \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# 安装Playwright的依赖
|
|
RUN apt-get update && apt-get install -y \
|
|
libnss3 \
|
|
libnspr4 \
|
|
libatk1.0-0 \
|
|
libatk-bridge2.0-0 \
|
|
libcups2 \
|
|
libdrm2 \
|
|
libdbus-1-3 \
|
|
libxkbcommon0 \
|
|
libxcomposite1 \
|
|
libxdamage1 \
|
|
libxfixes3 \
|
|
libxrandr2 \
|
|
libgbm1 \
|
|
libasound2 \
|
|
libpango-1.0-0 \
|
|
libpangocairo-1.0-0 \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# 配置pip源
|
|
RUN mkdir -p /root/.pip && \
|
|
echo "[global]" > /root/.pip/pip.conf && \
|
|
echo "index-url = https://pypi.tuna.tsinghua.edu.cn/simple" >> /root/.pip/pip.conf && \
|
|
echo "trusted-host = pypi.tuna.tsinghua.edu.cn" >> /root/.pip/pip.conf
|
|
|
|
# 更新pip
|
|
RUN python -m pip install --upgrade pip
|
|
|
|
RUN apt-get update && \
|
|
apt-get install -y --no-install-recommends tzdata && \
|
|
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \
|
|
dpkg-reconfigure -f noninteractive tzdata && \
|
|
rm -rf /var/lib/apt/lists/*
|
|
|
|
RUN pip install uv \
|
|
&& rm -rf /root/.cache/pip
|
|
|
|
ENV UV_INDEX_URL=https://pypi.tuna.tsinghua.edu.cn/simple
|
|
|
|
# 复制依赖文件
|
|
COPY requirements.txt .
|
|
|
|
# 配置清华源并安装 Python 依赖
|
|
# RUN pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple && \
|
|
# pip install --only-binary=all --no-cache-dir -r requirements.txt
|
|
|
|
RUN uv pip install --system -r requirements.txt
|
|
|
|
# 预先安装 Playwright 的系统依赖
|
|
RUN apt-get update && apt-get install -y \
|
|
xvfb \
|
|
libopengl0 \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# 安装中文字体
|
|
RUN apt-get update && apt-get install -y \
|
|
fonts-noto-cjk \
|
|
fonts-wqy-zenhei \
|
|
fonts-wqy-microhei \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# 安装Playwright浏览器
|
|
RUN playwright install chromium
|
|
RUN playwright install-deps
|
|
|
|
|
|
# 暴露端口
|
|
EXPOSE 80
|
|
|
|
# 运行应用
|
|
# CMD ["python", "update_data.py"] |