52 lines
2.0 KiB
Docker
52 lines
2.0 KiB
Docker
# 使用Python 3.9作为基础镜像
|
||
FROM python:3.9-slim
|
||
|
||
# 设置工作目录
|
||
WORKDIR /app
|
||
|
||
# 设置环境变量
|
||
ENV PYTHONPATH=/app
|
||
ENV PYTHONUNBUFFERED=1
|
||
ENV TZ=Asia/Shanghai
|
||
|
||
# 使用阿里云源替换默认的 Debian 源 (Debian 12 - Bookworm)
|
||
RUN echo "deb https://mirrors.tuna.tsinghua.edu.cn/debian bookworm main contrib non-free non-free-firmware" > /etc/apt/sources.list && \
|
||
echo "deb https://mirrors.tuna.tsinghua.edu.cn/debian bookworm-updates main contrib non-free non-free-firmware" >> /etc/apt/sources.list && \
|
||
echo "deb https://mirrors.tuna.tsinghua.edu.cn/debian bookworm-backports main contrib non-free non-free-firmware" >> /etc/apt/sources.list && \
|
||
echo "deb https://mirrors.tuna.tsinghua.edu.cn/debian-security bookworm-security main contrib non-free non-free-firmware" >> /etc/apt/sources.list
|
||
|
||
# 安装系统依赖和中文字体
|
||
RUN apt-get update && apt-get install -y \
|
||
build-essential \
|
||
tzdata \
|
||
fonts-wqy-microhei \
|
||
fonts-wqy-zenhei \
|
||
xfonts-wqy \
|
||
ttf-wqy-microhei \
|
||
ttf-wqy-zenhei \
|
||
&& rm -rf /var/lib/apt/lists/*
|
||
|
||
# 创建字体目录
|
||
RUN mkdir -p /app/src/fundamentals_llm/fonts
|
||
|
||
# 复制中文字体到应用目录
|
||
RUN cp /usr/share/fonts/truetype/wqy/wqy-microhei.ttc /app/src/fundamentals_llm/fonts/simhei.ttf || \
|
||
cp /usr/share/fonts/truetype/wqy/wqy-zenhei.ttc /app/src/fundamentals_llm/fonts/simhei.ttf || \
|
||
cp /usr/share/fonts/wqy-microhei/wqy-microhei.ttc /app/src/fundamentals_llm/fonts/simhei.ttf || \
|
||
cp /usr/share/fonts/wqy-zenhei/wqy-zenhei.ttc /app/src/fundamentals_llm/fonts/simhei.ttf || echo "Warning: Could not find WQY font, PDF generation may fail"
|
||
|
||
# 复制项目文件
|
||
COPY requirements.txt .
|
||
COPY src/ ./src/
|
||
|
||
# 安装Python依赖(使用阿里云源)
|
||
RUN pip install --no-cache-dir -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple
|
||
|
||
# 创建必要的目录
|
||
RUN mkdir -p /app/logs /app/reports
|
||
|
||
# 暴露端口
|
||
EXPOSE 5000
|
||
|
||
# 设置启动命令
|
||
CMD ["python", "src/app.py"] |