1oscon commited on
Commit
837de25
·
verified ·
1 Parent(s): 1f15691

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +12 -24
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,41 +13,29 @@ RUN apt-get update && apt-get install -y \
13
  # 2. 克隆项目
14
  RUN git clone https://github.com/CloudWaddie/LMArenaBridge.git .
15
 
16
- # 3. 【精准自动化修复补丁】使用 Python 脚本安全替换,解决所有报错
17
- RUN python3 -c ' \
18
- import os; \
19
- path = "src/main.py"; \
20
- content = open(path).read(); \
21
- # 修复端口 \
22
- content = content.replace("8000", "7860"); \
23
- # 修复超时:从 45秒 延长到 120秒 \
24
- content = content.replace("timeout=45000", "timeout=120000"); \
25
- # 修复 JS 报错:注入一段不带大括号的 JS 等待逻辑,防止破坏 Python f-string 语法 \
26
- js_wait = "await new Promise(r => setInterval(() => window.grecaptcha?.enterprise?.execute ? r() : null, 500)); await window.grecaptcha.enterprise.execute"; \
27
- content = content.replace("window.grecaptcha.enterprise.execute", js_wait); \
28
- # 确保启动参数正确 \
29
- content = content.replace("host=\"0.0.0.0\", port=8000", "host=\"0.0.0.0\", port=7860"); \
30
- with open(path, "w") as f: f.write(content); \
31
- print("✅ 补丁应用成功"); \
32
- '
33
-
34
- # 4. 强制创建配置文件,密码 123456
35
  RUN echo '{"admin_password": "123456", "password": "123456"}' > config.json
36
 
37
- # 5. 安装 Python 依赖
38
  RUN pip install --no-cache-dir --upgrade pip
39
  RUN pip install --no-cache-dir -r requirements.txt
40
  RUN pip install --no-cache-dir camoufox[geoip] playwright python-multipart
41
 
42
- # 6. 安装 Playwright 浏览器内核及依赖(Hugging Face 运行必备)
43
  RUN playwright install chromium
44
  RUN playwright install-deps chromium
45
 
46
- # 7. 下载 Camoufox 内核并配置
47
  RUN python -m camoufox fetch
48
  RUN chmod +x src/main.py
49
 
50
- # 环境适配
51
  ENV PYTHONUNBUFFERED=1
52
  ENV PORT=7860
53
 
 
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. 精准补丁修复(采用平铺式命令,杜绝缩进错误)
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 报错:在执行前强行等待 JS 环境就绪
20
+ RUN python3 -c "import os;p='src/main.py';c=open(p).read().replace('window.grecaptcha.enterprise.execute','await page.wait_for_function(\"() => window.grecaptcha && window.grecaptcha.enterprise && window.grecaptcha.enterprise.execute\"); await page.evaluate');open(p,'w').write(c)"
21
+
22
+ # 4. 强制创建配置文件,定死密码 123456
 
 
 
 
 
 
 
 
 
 
 
 
23
  RUN echo '{"admin_password": "123456", "password": "123456"}' > config.json
24
 
25
+ # 5. 安装依赖
26
  RUN pip install --no-cache-dir --upgrade pip
27
  RUN pip install --no-cache-dir -r requirements.txt
28
  RUN pip install --no-cache-dir camoufox[geoip] playwright python-multipart
29
 
30
+ # 6. 安装浏览器驱动及环境
31
  RUN playwright install chromium
32
  RUN playwright install-deps chromium
33
 
34
+ # 7. 下载 Camoufox 内核并授权
35
  RUN python -m camoufox fetch
36
  RUN chmod +x src/main.py
37
 
38
+ # 环境参数适配
39
  ENV PYTHONUNBUFFERED=1
40
  ENV PORT=7860
41