Use packaged Chromium driver in Docker

This commit is contained in:
2026-07-28 22:15:14 +03:30
parent 4462990d6f
commit 3982b03f5c
4 changed files with 50 additions and 21 deletions
+6 -17
View File
@@ -15,20 +15,9 @@ RUN uv sync --frozen --no-dev --no-install-project
# ── Stage 2: runtime ──────────────────────────────────────────────────────────
FROM python:3.11-slim AS runtime
# ── Chrome + system deps ──────────────────────────────────────────────────────
# ── Chromium + matching system ChromeDriver ───────────────────────────────────
RUN apt-get update && apt-get install -y --no-install-recommends \
wget gnupg ca-certificates curl unzip \
# X11 / rendering libs needed even in headless mode
libnss3 libatk1.0-0 libatk-bridge2.0-0 libcups2 libdrm2 \
libxkbcommon0 libxcomposite1 libxdamage1 libxfixes3 libxrandr2 \
libgbm1 libasound2 libpango-1.0-0 libcairo2 libx11-xcb1 \
&& wget -qO- https://dl.google.com/linux/linux_signing_key.pub \
| gpg --dearmor -o /usr/share/keyrings/google-chrome.gpg \
&& echo "deb [arch=amd64 signed-by=/usr/share/keyrings/google-chrome.gpg] \
http://dl.google.com/linux/chrome/deb/ stable main" \
> /etc/apt/sources.list.d/google-chrome.list \
&& apt-get update \
&& apt-get install -y --no-install-recommends google-chrome-stable \
ca-certificates curl chromium chromium-driver \
&& rm -rf /var/lib/apt/lists/*
# ── uv + venv from builder ────────────────────────────────────────────────────
@@ -41,8 +30,8 @@ ENV PATH="/app/.venv/bin:$PATH" \
PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
# Tell undetected-chromedriver where Chrome lives
CHROME_BINARY=/usr/bin/google-chrome-stable \
CHROMEDRIVER_PATH=/app/drivers/chromedriver \
CHROME_BINARY=/usr/bin/chromium \
CHROMEDRIVER_PATH=/usr/bin/chromedriver \
# Always run headless inside Docker
HEADLESS=true
@@ -52,8 +41,8 @@ COPY . .
# Copy this after the application so a host venv can never replace it.
COPY --from=builder /app/.venv /app/.venv
# Download and patch the matching driver at build time. Runtime jobs must not
# depend on undetected-chromedriver's network downloader.
# Patch Debian's version-matched driver at build time. Runtime jobs require no
# ChromeDriver network download.
RUN PYTHONPATH=. python scripts/patch_driver.py && mkdir -p data logs
# Non-root user for safety