Spaces:
Paused
Paused
Update Dockerfile
Browse files- Dockerfile +16 -21
Dockerfile
CHANGED
|
@@ -13,6 +13,7 @@ RUN apt-get update \
|
|
| 13 |
|
| 14 |
FROM python:3.13-slim-bookworm AS chrome-downloader
|
| 15 |
|
|
|
|
| 16 |
ARG CHROME_VERSION=136.0.7103.113
|
| 17 |
RUN apt-get update && apt-get install -y --no-install-recommends curl unzip \
|
| 18 |
&& curl -Lo /tmp/chrome.zip \
|
|
@@ -44,14 +45,10 @@ RUN dpkg -i /libgl1-mesa-dri.deb \
|
|
| 44 |
&& rm -rf /var/lib/apt/lists/* \
|
| 45 |
&& chmod a+rx /opt/chrome/chrome /usr/bin/chromedriver
|
| 46 |
|
| 47 |
-
#
|
| 48 |
-
# --
|
| 49 |
-
# --
|
| 50 |
-
# --disable-
|
| 51 |
-
# --window-size=1920,1080 : 模拟真实分辨率
|
| 52 |
-
# --lang=zh-CN : 模拟中文用户
|
| 53 |
-
# --disable-extensions-except / --disable-default-apps : 减少指纹
|
| 54 |
-
RUN printf '#!/bin/bash\nexec /opt/chrome/chrome \\\n --no-sandbox \\\n --disable-dev-shm-usage \\\n --disable-gpu \\\n --disable-blink-features=AutomationControlled \\\n --window-size=1920,1080 \\\n --lang=zh-CN \\\n --disable-extensions \\\n --disable-default-apps \\\n --no-first-run \\\n --disable-background-networking \\\n --disable-sync \\\n "$@"\n' \
|
| 55 |
> /usr/local/bin/google-chrome \
|
| 56 |
&& chmod a+rx /usr/local/bin/google-chrome \
|
| 57 |
&& google-chrome --version
|
|
@@ -70,21 +67,19 @@ USER user
|
|
| 70 |
|
| 71 |
RUN mkdir -p "/home/user/.config/chromium/Crash Reports/pending"
|
| 72 |
|
| 73 |
-
ENV
|
| 74 |
-
|
| 75 |
-
LOG_HTML=false \
|
| 76 |
-
# ★ 关键改动:false = 不传 --headless 给 Chrome,用 xvfb 虚拟显示代替
|
| 77 |
-
# Cloudflare 能检测 --headless 模式,xvfb 对它来说是"真实"的有头浏览器
|
| 78 |
-
HEADLESS=false \
|
| 79 |
-
CAPTCHA_SOLVER=none \
|
| 80 |
BROWSER_EXECUTABLE_PATH=/usr/local/bin/google-chrome \
|
| 81 |
-
#
|
| 82 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 83 |
|
| 84 |
EXPOSE 7860
|
| 85 |
|
| 86 |
-
# xvfb-run 参数:
|
| 87 |
-
|
| 88 |
-
# -a 自动选择可用的 display number
|
| 89 |
-
ENTRYPOINT ["dumb-init", "xvfb-run", "-a", "-s", "-screen 0 1920x1080x24"]
|
| 90 |
CMD ["python", "-u", "src/flaresolverr.py"]
|
|
|
|
| 13 |
|
| 14 |
FROM python:3.13-slim-bookworm AS chrome-downloader
|
| 15 |
|
| 16 |
+
# Chrome 136 stable(可按需换版本号)
|
| 17 |
ARG CHROME_VERSION=136.0.7103.113
|
| 18 |
RUN apt-get update && apt-get install -y --no-install-recommends curl unzip \
|
| 19 |
&& curl -Lo /tmp/chrome.zip \
|
|
|
|
| 45 |
&& rm -rf /var/lib/apt/lists/* \
|
| 46 |
&& chmod a+rx /opt/chrome/chrome /usr/bin/chromedriver
|
| 47 |
|
| 48 |
+
# ══ wrapper:只注入必须的沙盒参数,不加任何 headless/gpu 标志 ══
|
| 49 |
+
# 关键:去掉 --disable-gpu,让 xvfb 提供完整的 GPU 环境
|
| 50 |
+
# 去掉 --headless,改由 HEADLESS=false + xvfb 实现无屏幕运行
|
| 51 |
+
RUN printf '#!/bin/bash\nexec /opt/chrome/chrome --no-sandbox --disable-dev-shm-usage "$@"\n' \
|
|
|
|
|
|
|
|
|
|
|
|
|
| 52 |
> /usr/local/bin/google-chrome \
|
| 53 |
&& chmod a+rx /usr/local/bin/google-chrome \
|
| 54 |
&& google-chrome --version
|
|
|
|
| 67 |
|
| 68 |
RUN mkdir -p "/home/user/.config/chromium/Crash Reports/pending"
|
| 69 |
|
| 70 |
+
ENV LOG_LEVEL=info \
|
| 71 |
+
PORT=7860 \
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 72 |
BROWSER_EXECUTABLE_PATH=/usr/local/bin/google-chrome \
|
| 73 |
+
# ★ 关键优化1:关闭 headless 模式,使用 xvfb 虚拟显示器
|
| 74 |
+
# headless Chrome 有大量可被 Cloudflare 检测的 fingerprint
|
| 75 |
+
HEADLESS=false \
|
| 76 |
+
# ★ 关键优化2:指定 xvfb 虚拟屏幕编号,确保 Chrome 使用虚拟显示
|
| 77 |
+
DISPLAY=:99 \
|
| 78 |
+
# ★ 优化3:延长超时,给 Cloudflare 挑战更多求解时间
|
| 79 |
+
BROWSER_TIMEOUT=60000
|
| 80 |
|
| 81 |
EXPOSE 7860
|
| 82 |
|
| 83 |
+
# xvfb-run 参数:-s 指定屏幕分辨率为 1920x1080,模拟真实显示器
|
| 84 |
+
ENTRYPOINT ["dumb-init", "xvfb-run", "-a", "-s", "-screen 0 1920x1080x24 -ac"]
|
|
|
|
|
|
|
| 85 |
CMD ["python", "-u", "src/flaresolverr.py"]
|