# 使用中科大镜像源的 Python 基础镜像 FROM python:3.11.15-slim # 设置工作目录 WORKDIR /app # 设置环境变量 ENV PYTHONDONTWRITEBYTECODE=1 ENV PYTHONUNBUFFERED=1 ENV FLASK_RUN_HOST=0.0.0.0 # 安装系统依赖(用于 git 等工具) RUN apt-get update && apt-get install -y --no-install-recommends \ git \ && rm -rf /var/lib/apt/lists/* # 复制依赖文件 COPY requirements.txt . # 安装 Python 依赖(显式安装,避免缓存导致遗漏) RUN pip install --no-cache-dir -r requirements.txt \ && pip install --no-cache-dir "GitPython>=3.1.0" "gitdb>=4.0.1" "smmap>=3.0.1" # 复制应用代码 COPY . . # 创建报告目录 RUN mkdir -p reports # 暴露端口 EXPOSE 5000 # 启动应用 CMD ["python", "app.py"]