Switch Playwright to headless — Xvfb fails on Proxmox LXC kernels

Xvfb exits immediately on the production LXC (no framebuffer device
support), so headed mode was never working. Switch to headless=True
and remove Xvfb from the Dockerfile entirely.

Stealth coverage is unchanged: playwright-stealth patches webdriver,
plugins and chrome.runtime; the residential proxy + sticky session
provide the GB residential fingerprint; homepage warmup carries real
session cookies into the search. --enable-unsafe-swiftshader and
--disable-blink-features=AutomationControlled are kept.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
jtricerolph 2026-07-09 17:01:54 +00:00
parent e781b1e8b9
commit 617ff932bb
2 changed files with 7 additions and 10 deletions

View file

@ -7,7 +7,6 @@ RUN apt-get update && apt-get install -y \
libpq-dev \ libpq-dev \
postgresql-client \ postgresql-client \
curl \ curl \
xvfb \
&& rm -rf /var/lib/apt/lists/* && rm -rf /var/lib/apt/lists/*
COPY requirements.txt . COPY requirements.txt .
@ -20,9 +19,4 @@ COPY . .
EXPOSE 8000 EXPOSE 8000
# Run under a virtual X display so Chromium launches headful (headful fingerprints CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]
# far cleaner than headless — real GPU strings, plugins, chrome.runtime).
# Start Xvfb directly rather than via xvfb-run: as container PID 1, xvfb-run's
# SIGUSR1 readiness handshake never fires and it hangs without exec'ing the app.
ENV DISPLAY=:99
CMD ["/bin/sh", "-c", "Xvfb :99 -screen 0 1920x1080x24 -nolisten tcp & sleep 1; exec uvicorn main:app --host 0.0.0.0 --port 8000"]

View file

@ -159,14 +159,17 @@ class PlaywrightLocalBackend(ScraperBackend):
if self._playwright is None: if self._playwright is None:
self._playwright = await async_playwright().start() self._playwright = await async_playwright().start()
launch_kwargs = dict( launch_kwargs = dict(
# Headful under xvfb — far cleaner fingerprint than headless. # Headless — stealth patches + residential proxy + session
headless=False, # cookies cover the fingerprint; headed+xvfb is unreliable
# in Proxmox LXC kernels where Xvfb exits immediately.
headless=True,
args=[ args=[
'--disable-blink-features=AutomationControlled', '--disable-blink-features=AutomationControlled',
'--no-sandbox', '--no-sandbox',
'--disable-dev-shm-usage', '--disable-dev-shm-usage',
'--disable-features=IsolateOrigins,site-per-process', '--disable-features=IsolateOrigins,site-per-process',
'--start-maximized', '--disable-gpu',
'--enable-unsafe-swiftshader',
], ],
) )
# Proxy is set at launch (Chromium binds the sticky session, which # Proxy is set at launch (Chromium binds the sticky session, which