fix(docker): drop the unused selenium-manager binaries from the image (#1615)

Came out of looking at what is in the image after @wrycu's #1606. The
selenium package ships prebuilt `selenium-manager` binaries for four
platforms (about 22MB uncompressed), and none of them are used here.
They only run when selenium has to find a webdriver, and the bypasser
drives the browser through SeleniumBase's Pure-CDP driver, which doesn't
use one.

This deletes them (and their SBOM file) in the same `RUN` as `uv sync`,
so the layer doesn't carry them. As a side effect image scanners stop
reporting on the Rust crates compiled into those binaries.

To check nothing needs them, I deleted the files in a throwaway
container from the current `dev` image and ran `internal_bypasser.get()`
against example.com. It started the browser, loaded the page and
returned it, same as without the deletion. I haven't run a full image
build of this branch, so CI is the first time that exact `RUN` line gets
executed.

TL;DR dropping an unused feature from an included package lowering size
and eliminating flags for security vulnerabilities that don't get
exercised.

@calibrain this one is optional too, but I don't see a downside, your
call.
This commit is contained in:
splitsec2 authored and GitHub committed 2026-10-31 01:21:05 -06:00
1 parent 3d7d04256f
commit d04268c639
1 file changed
+6 -1
+6 -1
View File
@@ -180,7 +180,12 @@ RUN echo "deb [check-valid-until=no] https://snapshot.debian.org/archive/debian-
# Install the browser automation stack used by the full image
RUN --mount=type=cache,target=/root/.cache/uv \
--mount=from=uv,source=/uv,target=/usr/local/bin/uv \
uv sync --locked --no-default-groups --extra browser
uv sync --locked --no-default-groups --extra browser && \
# Selenium ships prebuilt selenium-manager binaries (about 22MB) for every
# platform. They only run when selenium has to locate a webdriver, and the
# bypasser drives the browser through SeleniumBase's Pure-CDP driver, which
# needs none. Removed in this layer so the image does not carry them.
find /app/.venv/lib -name 'selenium-manager*' -delete
# Deterministically resolve the Xlib namespace collision.
# pyautogui/mouseinfo pull the stale `python3-xlib` (0.15, 2014), while the