Update Dockerfile
Browse files- 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.
|
| 17 |
-
RUN
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 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.
|
| 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.
|
| 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 |
|