feat: add explicit Chrome installation and pre-download chromedriver in Docker build

This commit is contained in:
2026-02-13 16:03:49 +01:00
parent 9659382d62
commit 448b486672

View File

@@ -1,8 +1,8 @@
FROM python:3.12-slim FROM --platform=linux/amd64 python:3.12-slim
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/ COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
# Install system dependencies for Chrome / SeleniumBase # Install system dependencies + Google Chrome
RUN apt-get update && apt-get install -y --no-install-recommends \ RUN apt-get update && apt-get install -y --no-install-recommends \
wget \ wget \
gnupg2 \ gnupg2 \
@@ -23,6 +23,9 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
libxdamage1 \ libxdamage1 \
libxrandr2 \ libxrandr2 \
xdg-utils \ xdg-utils \
&& wget -q -O /tmp/google-chrome.deb https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb \
&& apt-get install -y --no-install-recommends /tmp/google-chrome.deb \
&& rm /tmp/google-chrome.deb \
&& rm -rf /var/lib/apt/lists/* && rm -rf /var/lib/apt/lists/*
WORKDIR /app WORKDIR /app
@@ -40,6 +43,9 @@ COPY . /app
RUN --mount=type=cache,target=/root/.cache/uv \ RUN --mount=type=cache,target=/root/.cache/uv \
uv sync --locked uv sync --locked
# Pre-download chromedriver matching installed Chrome
RUN uv run python -c "from seleniumbase import Driver; d = Driver(uc=True, headless=True); d.quit()"
ENV HEADLESS_BROWSER=True ENV HEADLESS_BROWSER=True
ENV PORT=4001 ENV PORT=4001