1oscon commited on
Commit
03a1a0e
·
verified ·
1 Parent(s): 591a124

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +22 -11
Dockerfile CHANGED
@@ -13,15 +13,26 @@ RUN apt-get update && apt-get install -y \
13
  # 2. 克隆项目
14
  RUN git clone https://github.com/CloudWaddie/LMArenaBridge.git .
15
 
16
- # 3. 【极强容错补丁】平铺式命令,解决跳转导致的 evaluate 失败
17
- RUN sed -i 's/8000/7860/g' src/main.py
18
- RUN sed -i 's/timeout=45000/timeout=120000/g' src/main.py
19
- # 核心补丁:在获取 recaptcha 前,强制等待页面网络空闲,防止跳转冲突,并增加 evaluate 的异常捕获
20
- RUN python3 -c "import os;p='src/main.py';c=open(p).read();\
21
- c=c.replace('window.grecaptcha.enterprise.execute', 'await page.wait_for_load_state(\"networkidle\"); await page.wait_for_function(\"() => window.grecaptcha?.enterprise?.execute\"); await page.evaluate');\
22
- open(p,'w').write(c)"
23
-
24
- # 4. 强制配置文件,密码 123456
 
 
 
 
 
 
 
 
 
 
 
25
  RUN echo '{"admin_password": "123456", "password": "123456"}' > config.json
26
 
27
  # 5. 安装依赖
@@ -29,11 +40,11 @@ RUN pip install --no-cache-dir --upgrade pip
29
  RUN pip install --no-cache-dir -r requirements.txt
30
  RUN pip install --no-cache-dir camoufox[geoip] playwright python-multipart
31
 
32
- # 6. 安装浏览器
33
  RUN playwright install chromium
34
  RUN playwright install-deps chromium
35
 
36
- # 7. 下载内核
37
  RUN python -m camoufox fetch
38
  RUN chmod +x src/main.py
39
 
 
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. 安装依赖
 
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
 
47
+ # 7. 下载内核并授权
48
  RUN python -m camoufox fetch
49
  RUN chmod +x src/main.py
50