FROM python:3.13-slim # 1. 环境配置 ENV PYTHONUNBUFFERED=1 \ DISPLAY=:99 \ DEBIAN_FRONTEND=noninteractive # 2. 安装系统依赖 (包含 Chrome) RUN apt-get update && apt-get install -y --no-install-recommends \ wget gnupg curl git xvfb unzip \ fonts-liberation libasound2t64 libatk-bridge2.0-0t64 libatk1.0-0t64 \ libatspi2.0-0t64 libcups2t64 libdbus-1-3 libdrm2 libgbm1 libgtk-3-0t64 \ libnspr4 libnss3 libxcomposite1 libxdamage1 libxfixes3 \ libxkbcommon0 libxrandr2 xdg-utils \ && wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | gpg --dearmor -o /usr/share/keyrings/google-chrome.gpg \ && echo "deb [arch=amd64 signed-by=/usr/share/keyrings/google-chrome.gpg] http://dl.google.com/linux/chrome/deb/ stable main" > /etc/apt/sources.list.d/google-chrome.list \ && apt-get update && apt-get install -y --no-install-recommends google-chrome-stable \ && apt-get clean && rm -rf /var/lib/apt/lists/* \ && pip install --no-cache-dir uv # 3. 设置 HF 要求的用户 RUN useradd -m -u 1000 user USER user WORKDIR /home/user/app # 4. 克隆代码并强制整理目录结构 RUN git clone --depth 1 https://github.com/Starry-Sky-World/gar.git . && \ if [ -d "py" ]; then cp -r py/* . ; fi # 5. 核心修复:自动读取项目依赖文件并安装到系统路径 # 额外强制安装 waitress (解决刚才的报错) 和 setuptools (解决 distutils 报错) RUN uv pip install --system --no-cache . 2>/dev/null || \ uv pip install --system --no-cache -r pyproject.toml 2>/dev/null || \ pip install --no-cache-dir flask waitress setuptools undetected-chromedriver selenium pyyaml faker requests webdavclient3 # 6. 配置文件 RUN cp config.example.yaml config.yaml 2>/dev/null || true EXPOSE 7860 # 7. 启动 CMD ["sh", "-c", "Xvfb :99 -screen 0 1920x1080x24 & sleep 3 && python server.py"]