Spaces:
Paused
Paused
Update Dockerfile
Browse files- Dockerfile +19 -17
Dockerfile
CHANGED
|
@@ -11,9 +11,10 @@ RUN apt-get update \
|
|
| 11 |
&& equivs-build adwaita-icon-theme \
|
| 12 |
&& mv adwaita-icon-theme_*.deb /adwaita-icon-theme.deb
|
| 13 |
|
|
|
|
| 14 |
FROM python:3.13-slim-bookworm AS chrome-downloader
|
| 15 |
|
| 16 |
-
ARG CHROME_VERSION=
|
| 17 |
RUN apt-get update && apt-get install -y --no-install-recommends curl unzip \
|
| 18 |
&& curl -Lo /tmp/chrome.zip \
|
| 19 |
"https://storage.googleapis.com/chrome-for-testing-public/${CHROME_VERSION}/linux64/chrome-linux64.zip" \
|
|
@@ -21,10 +22,10 @@ RUN apt-get update && apt-get install -y --no-install-recommends curl unzip \
|
|
| 21 |
"https://storage.googleapis.com/chrome-for-testing-public/${CHROME_VERSION}/linux64/chromedriver-linux64.zip" \
|
| 22 |
&& unzip /tmp/chrome.zip -d /opt/ \
|
| 23 |
&& unzip /tmp/chromedriver.zip -d /opt/ \
|
| 24 |
-
# ← FIX: 让所有用户都可读可执行
|
| 25 |
&& chmod -R a+rx /opt/chrome-linux64 \
|
| 26 |
&& chmod a+rx /opt/chromedriver-linux64/chromedriver
|
| 27 |
|
|
|
|
| 28 |
FROM python:3.13-slim-bookworm
|
| 29 |
|
| 30 |
COPY --from=builder /*.deb /
|
|
@@ -35,25 +36,25 @@ RUN dpkg -i /libgl1-mesa-dri.deb \
|
|
| 35 |
&& dpkg -i /adwaita-icon-theme.deb \
|
| 36 |
&& apt-get update \
|
| 37 |
&& apt-get install -y --no-install-recommends \
|
| 38 |
-
|
| 39 |
-
libnss3 libnspr4 \
|
| 40 |
-
libatk1.0-0 libatk-bridge2.0-0 \
|
| 41 |
-
libcups2 libdrm2 \
|
| 42 |
libxkbcommon0 libxcomposite1 libxdamage1 libxfixes3 libxrandr2 \
|
| 43 |
-
libgbm1 libasound2 \
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
libglib2.0-0 libdbus-1-3 \
|
| 47 |
-
libx11-6 libxcb1 libxext6 \
|
| 48 |
-
libfontconfig1 libfreetype6 libexpat1 \
|
| 49 |
fonts-liberation \
|
| 50 |
xvfb dumb-init git procps curl xauth \
|
| 51 |
&& rm -rf /var/lib/apt/lists/* \
|
| 52 |
-
# ← FIX: 验证 Chrome 能正常调用(root 下无需 --no-sandbox)
|
| 53 |
-
&& /opt/chrome/chrome --version --no-sandbox \
|
| 54 |
-
# ← FIX: 再次确保权限(apt 操作后不变,但显式保险)
|
| 55 |
&& chmod a+rx /opt/chrome/chrome /usr/bin/chromedriver
|
| 56 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 57 |
RUN useradd -m -u 1000 user
|
| 58 |
|
| 59 |
WORKDIR /app
|
|
@@ -66,12 +67,13 @@ RUN pip install -r requirements.txt --no-cache-dir \
|
|
| 66 |
|
| 67 |
USER user
|
| 68 |
|
| 69 |
-
RUN mkdir -p "/
|
| 70 |
|
| 71 |
ENV LOG_LEVEL=info \
|
| 72 |
HEADLESS=true \
|
| 73 |
PORT=7860 \
|
| 74 |
-
|
|
|
|
| 75 |
|
| 76 |
EXPOSE 7860
|
| 77 |
|
|
|
|
| 11 |
&& equivs-build adwaita-icon-theme \
|
| 12 |
&& mv adwaita-icon-theme_*.deb /adwaita-icon-theme.deb
|
| 13 |
|
| 14 |
+
# ── 下载 Chrome for Testing 136.0.7103.113 ──
|
| 15 |
FROM python:3.13-slim-bookworm AS chrome-downloader
|
| 16 |
|
| 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 \
|
| 20 |
"https://storage.googleapis.com/chrome-for-testing-public/${CHROME_VERSION}/linux64/chrome-linux64.zip" \
|
|
|
|
| 22 |
"https://storage.googleapis.com/chrome-for-testing-public/${CHROME_VERSION}/linux64/chromedriver-linux64.zip" \
|
| 23 |
&& unzip /tmp/chrome.zip -d /opt/ \
|
| 24 |
&& unzip /tmp/chromedriver.zip -d /opt/ \
|
|
|
|
| 25 |
&& chmod -R a+rx /opt/chrome-linux64 \
|
| 26 |
&& chmod a+rx /opt/chromedriver-linux64/chromedriver
|
| 27 |
|
| 28 |
+
# ── 最终镜像 ──
|
| 29 |
FROM python:3.13-slim-bookworm
|
| 30 |
|
| 31 |
COPY --from=builder /*.deb /
|
|
|
|
| 36 |
&& dpkg -i /adwaita-icon-theme.deb \
|
| 37 |
&& apt-get update \
|
| 38 |
&& apt-get install -y --no-install-recommends \
|
| 39 |
+
libnss3 libnspr4 libatk1.0-0 libatk-bridge2.0-0 libcups2 libdrm2 \
|
|
|
|
|
|
|
|
|
|
| 40 |
libxkbcommon0 libxcomposite1 libxdamage1 libxfixes3 libxrandr2 \
|
| 41 |
+
libgbm1 libasound2 libpango-1.0-0 libcairo2 libatspi2.0-0 \
|
| 42 |
+
libwayland-client0 libglib2.0-0 libdbus-1-3 \
|
| 43 |
+
libx11-6 libxcb1 libxext6 libfontconfig1 libfreetype6 libexpat1 \
|
|
|
|
|
|
|
|
|
|
| 44 |
fonts-liberation \
|
| 45 |
xvfb dumb-init git procps curl xauth \
|
| 46 |
&& rm -rf /var/lib/apt/lists/* \
|
|
|
|
|
|
|
|
|
|
| 47 |
&& chmod a+rx /opt/chrome/chrome /usr/bin/chromedriver
|
| 48 |
|
| 49 |
+
# ══ 核心修复:wrapper 脚本,让所有 chrome 调用自动带 --no-sandbox ══
|
| 50 |
+
# FlareSolverr 检测时调用 `chrome --version`,不带 --no-sandbox 会在
|
| 51 |
+
# HF 非特权容器里直接崩溃,导致误报"未安装"。wrapper 透明注入该参数。
|
| 52 |
+
RUN printf '#!/bin/bash\nexec /opt/chrome/chrome --no-sandbox --disable-dev-shm-usage --disable-gpu "$@"\n' \
|
| 53 |
+
> /usr/local/bin/google-chrome \
|
| 54 |
+
&& chmod a+rx /usr/local/bin/google-chrome \
|
| 55 |
+
# 验证 wrapper 可正常输出版本号(build 阶段即拦截问题)
|
| 56 |
+
&& google-chrome --version
|
| 57 |
+
|
| 58 |
RUN useradd -m -u 1000 user
|
| 59 |
|
| 60 |
WORKDIR /app
|
|
|
|
| 67 |
|
| 68 |
USER user
|
| 69 |
|
| 70 |
+
RUN mkdir -p "/home/user/.config/chromium/Crash Reports/pending"
|
| 71 |
|
| 72 |
ENV LOG_LEVEL=info \
|
| 73 |
HEADLESS=true \
|
| 74 |
PORT=7860 \
|
| 75 |
+
# 指向 wrapper 脚本而非直接指向二进制
|
| 76 |
+
BROWSER_EXECUTABLE_PATH=/usr/local/bin/google-chrome
|
| 77 |
|
| 78 |
EXPOSE 7860
|
| 79 |
|