File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -4,33 +4,14 @@ WORKDIR /app
44
55ENV PYTHONDONTWRITEBYTECODE=1 \
66 PYTHONUNBUFFERED=1 \
7- ALLOW_DOCKER_HEADED_CAPTCHA=true
7+ ALLOW_DOCKER_HEADED_CAPTCHA=true \
8+ PLAYWRIGHT_BROWSERS_PATH=0
89
9- # 安装 Chrome 运行依赖(无头模式仍需要这些系统库)
10+ # 在镜像构建阶段预装 Playwright Chromium,供 personal/browser 模式复用
1011COPY requirements.txt ./
1112
12- RUN apt-get update \
13- && apt-get install -y --no-install-recommends \
14- ca-certificates \
15- curl \
16- libnss3 \
17- libnspr4 \
18- libatk1.0-0 \
19- libatk-bridge2.0-0 \
20- libcups2 \
21- libdrm2 \
22- libxkbcommon0 \
23- libxcomposite1 \
24- libxdamage1 \
25- libxfixes3 \
26- libxrandr2 \
27- libgbm1 \
28- libpango-1.0-0 \
29- libcairo2 \
30- libasound2 \
31- && rm -rf /var/lib/apt/lists/*
32-
33- RUN pip install --no-cache-dir --root-user-action=ignore -r requirements.txt
13+ RUN pip install --no-cache-dir --root-user-action=ignore -r requirements.txt \
14+ && python -m playwright install --with-deps chromium
3415
3516COPY . .
3617COPY docker/entrypoint.headed.sh /usr/local/bin/entrypoint.headed.sh
Original file line number Diff line number Diff line change 11#! /bin/sh
22set -eu
33
4+ resolve_browser_path () {
5+ python - << 'PY '
6+ from playwright.sync_api import sync_playwright
7+
8+ with sync_playwright() as p:
9+ print(p.chromium.executable_path or "")
10+ PY
11+ }
12+
13+ if [ -z " ${BROWSER_EXECUTABLE_PATH:- } " ] || [ ! -x " ${BROWSER_EXECUTABLE_PATH:- } " ]; then
14+ detected_browser_path=" $( resolve_browser_path 2> /dev/null | tr -d ' \r' | tail -n 1) "
15+ if [ -n " ${detected_browser_path} " ] && [ -x " ${detected_browser_path} " ]; then
16+ export BROWSER_EXECUTABLE_PATH=" ${detected_browser_path} "
17+ fi
18+ fi
19+
420echo " [entrypoint] starting flow2api (headless browser mode)"
21+ if [ -n " ${BROWSER_EXECUTABLE_PATH:- } " ] && [ -x " ${BROWSER_EXECUTABLE_PATH} " ]; then
22+ echo " [entrypoint] browser executable: ${BROWSER_EXECUTABLE_PATH} "
23+ " ${BROWSER_EXECUTABLE_PATH} " --version || true
24+ else
25+ echo " [entrypoint] warning: no valid browser executable found for personal/browser captcha" >&2
26+ fi
27+
528exec python main.py
You can’t perform that action at this time.
0 commit comments