FROM python:3.10-slim WORKDIR /app # 1. 安装系统依赖 (保持不变) RUN apt-get update && apt-get install -y \ git wget curl unzip \ libnss3 libnspr4 libatk1.0-0 libatk-bridge2.0-0 libcups2 libdrm2 \ libxkbcommon0 libxcomposite1 libxdamage1 libxfixes3 libxrandr2 \ libgbm1 libasound2 libpango-1.0-0 libcairo2 libgtk-3-0 \ && rm -rf /var/lib/apt/lists/* # 2. 克隆项目 RUN git clone https://github.com/CloudWaddie/LMArenaBridge.git . # 3. 【修复版补丁】解决 IndentationError & 应用逻辑修复 # 关键修改:将 Python 脚本压缩为单行或去除行首空格,避免 Docker 传递错误的缩进 RUN python3 -c 'import os; p = "src/main.py"; c = open(p).read(); c = c.replace("8000", "7860"); c = c.replace("timeout=45000", "timeout=120000"); old_code = "token = await page.evaluate"; new_code = "await asyncio.sleep(5); await page.wait_for_load_state(\"networkidle\"); token = await page.evaluate"; c = c.replace(old_code, new_code); c = c.replace("window.grecaptcha.enterprise.execute", "await page.wait_for_function(\"() => window.grecaptcha?.enterprise?.execute\"); await window.grecaptcha.enterprise.execute"); open(p, "w").write(c); print("✅ 深度修复补丁已应用");' # 4. 强制创建配置文件 RUN echo '{"admin_password": "123456", "password": "123456"}' > config.json # 5. 安装依赖 RUN pip install --no-cache-dir --upgrade pip RUN pip install --no-cache-dir -r requirements.txt # ⚠️ 新增:httpx (你的代码中用到了它,必须安装,否则运行会报错) RUN pip install --no-cache-dir camoufox[geoip] playwright python-multipart httpx # 6. 安装浏览器核心 RUN playwright install chromium RUN playwright install-deps chromium # 7. 下载内核并授权 RUN python -m camoufox fetch RUN chmod +x src/main.py # 环境适配 ENV PYTHONUNBUFFERED=1 ENV PORT=7860 CMD ["python", "src/main.py"]