1oscon commited on
Commit
46c9fe6
·
verified ·
1 Parent(s): 03a1a0e

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +9 -23
Dockerfile CHANGED
@@ -2,7 +2,7 @@ FROM python:3.10-slim
2
 
3
  WORKDIR /app
4
 
5
- # 1. 安装系统依赖
6
  RUN apt-get update && apt-get install -y \
7
  git wget curl unzip \
8
  libnss3 libnspr4 libatk1.0-0 libatk-bridge2.0-0 libcups2 libdrm2 \
@@ -13,34 +13,20 @@ RUN apt-get update && apt-get install -y \
13
  # 2. 克隆项目
14
  RUN git clone https://github.com/CloudWaddie/LMArenaBridge.git .
15
 
16
- # 3. 【神级补丁】解决跳转冲突 & 端口适配
17
- RUN python3 -c ' \
18
- import os; \
19
- p = "src/main.py"; \
20
- c = open(p).read(); \
21
- # 1. 适配端口 \
22
- c = c.replace("8000", "7860"); \
23
- # 2. 延长超时 \
24
- c = c.replace("timeout=45000", "timeout=120000"); \
25
- # 3. 核心修复:在执行 reCAPTCHA 前强行增加 5秒稳固期,并捕获环境销毁异常 \
26
- old_code = "token = await page.evaluate"; \
27
- new_code = "await asyncio.sleep(5); await page.wait_for_load_state(\"networkidle\"); token = await page.evaluate"; \
28
- c = c.replace(old_code, new_code); \
29
- # 4. 修复 JS 对象检测,防止 is not a function \
30
- c = c.replace("window.grecaptcha.enterprise.execute", "await page.wait_for_function(\"() => window.grecaptcha?.enterprise?.execute\"); await window.grecaptcha.enterprise.execute"); \
31
- with open(p, "w") as f: f.write(c); \
32
- print("✅ 深度修复补丁已应用"); \
33
- '
34
-
35
- # 4. 强制创建配置文件,密码 123456
36
  RUN echo '{"admin_password": "123456", "password": "123456"}' > config.json
37
 
38
  # 5. 安装依赖
39
  RUN pip install --no-cache-dir --upgrade pip
40
  RUN pip install --no-cache-dir -r requirements.txt
41
- RUN pip install --no-cache-dir camoufox[geoip] playwright python-multipart
 
42
 
43
- # 6. 安装浏览器核心(必须包含 deps)
44
  RUN playwright install chromium
45
  RUN playwright install-deps chromium
46
 
 
2
 
3
  WORKDIR /app
4
 
5
+ # 1. 安装系统依赖 (保持不变)
6
  RUN apt-get update && apt-get install -y \
7
  git wget curl unzip \
8
  libnss3 libnspr4 libatk1.0-0 libatk-bridge2.0-0 libcups2 libdrm2 \
 
13
  # 2. 克隆项目
14
  RUN git clone https://github.com/CloudWaddie/LMArenaBridge.git .
15
 
16
+ # 3. 【修复版补丁】解决 IndentationError & 应用逻辑修复
17
+ # 关键修改:将 Python 脚本压缩为单行或去除行首空格,避免 Docker 传递错误的缩进
18
+ 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("✅ 深度修复补丁已应用");'
19
+
20
+ # 4. 强制创建配置文件
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
  RUN echo '{"admin_password": "123456", "password": "123456"}' > config.json
22
 
23
  # 5. 安装依赖
24
  RUN pip install --no-cache-dir --upgrade pip
25
  RUN pip install --no-cache-dir -r requirements.txt
26
+ # ⚠️ 新增:httpx (你的代码中用到了它,必须安装,否则运行会报错)
27
+ RUN pip install --no-cache-dir camoufox[geoip] playwright python-multipart httpx
28
 
29
+ # 6. 安装浏览器核心
30
  RUN playwright install chromium
31
  RUN playwright install-deps chromium
32