Update Dockerfile
Browse files- Dockerfile +19 -6
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,19 +13,32 @@ 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 |
-
# 4.
|
| 20 |
-
# 这样系统就不会再去用那个未知的默认密码了
|
| 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 |
RUN pip install --no-cache-dir camoufox[geoip] playwright python-multipart
|
|
|
|
| 27 |
|
| 28 |
# 6. 下载内核并启动
|
| 29 |
RUN python -m camoufox fetch
|
| 30 |
RUN chmod +x src/main.py
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
CMD ["python", "src/main.py"]
|
|
|
|
| 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. 【核心修复补丁】一键解决 JS 报错、超时和端口问题
|
| 17 |
+
RUN echo "正在应用自动化修复补丁..." && \
|
| 18 |
+
# 修复 JS 报错:在调用 recaptcha 前强制等待库加载完成
|
| 19 |
+
sed -i 's/window.grecaptcha.enterprise.execute/await new Promise(r => { let i = setInterval(() => { if(window.grecaptcha?.enterprise?.execute) { clearInterval(i); r(); } }, 500); }); window.grecaptcha.enterprise.execute/g' src/main.py && \
|
| 20 |
+
# 修复超时:将 45秒超时延长至 120秒,给 Cloudflare 足够时间
|
| 21 |
+
sed -i 's/timeout=45000/timeout=120000/g' src/main.py && \
|
| 22 |
+
# 修正端口
|
| 23 |
+
sed -i 's/8000/7860/g' src/main.py && \
|
| 24 |
+
# 修正 Uvicorn 运行参数以适配 HF
|
| 25 |
+
sed -i 's/host="0.0.0.0", port=8000/host="0.0.0.0", port=7860/g' src/main.py
|
| 26 |
|
| 27 |
+
# 4. 强制创建配置文件,密码定死为 123456
|
|
|
|
| 28 |
RUN echo '{"admin_password": "123456", "password": "123456"}' > config.json
|
| 29 |
|
| 30 |
+
# 5. 安装依赖 (增加 playwright 核心)
|
| 31 |
RUN pip install --no-cache-dir --upgrade pip
|
| 32 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 33 |
RUN pip install --no-cache-dir camoufox[geoip] playwright python-multipart
|
| 34 |
+
RUN playwright install chromium && playwright install-deps
|
| 35 |
|
| 36 |
# 6. 下载内核并启动
|
| 37 |
RUN python -m camoufox fetch
|
| 38 |
RUN chmod +x src/main.py
|
| 39 |
+
|
| 40 |
+
# 设置环境变量,强制不使用代理(防止 HF 内网冲突)
|
| 41 |
+
ENV HTTP_PROXY=""
|
| 42 |
+
ENV HTTPS_PROXY=""
|
| 43 |
+
|
| 44 |
CMD ["python", "src/main.py"]
|