File size: 1,890 Bytes
688994b 46c9fe6 688994b 1b58062 688994b 46c9fe6 1b58062 837de25 688994b 46c9fe6 688994b 46c9fe6 1f15691 03a1a0e 688994b 0ad7433 591a124 1f15691 0ad7433 688994b | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | 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"] |