Skip to content

chore: add virtualenv and uv to selenium container#704

Draft
ssbarnea wants to merge 1 commit intomainfrom
chore/selenium
Draft

chore: add virtualenv and uv to selenium container#704
ssbarnea wants to merge 1 commit intomainfrom
chore/selenium

Conversation

@ssbarnea
Copy link
Copy Markdown
Member

@ssbarnea ssbarnea commented Mar 11, 2026

This should fix the issue of newer python-venv vscode extension failing to find any tools/environments to use.

Copilot AI review requested due to automatic review settings March 11, 2026 15:02
@ssbarnea ssbarnea requested a review from a team as a code owner March 11, 2026 15:02
@ssbarnea ssbarnea enabled auto-merge (squash) March 11, 2026 15:02
@github-actions github-actions bot added the chore label Mar 11, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the selenium container image to include virtualenv and the uv toolchain, enabling installation of the project wheel via uv pip and provisioning multiple Python runtimes inside the container.

Changes:

  • Prepends /home/selenium/.local/bin to PATH in the container environment.
  • Adds python3-virtualenv to the installed RPM package set.
  • Installs uv, uses it to install the ansible_dev_tools wheel, and installs multiple Python versions via uv python install.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +190 to +191
# /home/selenium
RUN uv python install 3.10 3.11 3.12 3.13 3.14
Copy link

Copilot AI Mar 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uv python install ... will download multiple interpreter distributions during the build, but this layer doesn’t use a BuildKit cache mount for uv’s download/cache directory. Adding a cache mount aligned to uv’s cache location (or setting UV_CACHE_DIR to a mounted path) can significantly speed up rebuilds and reduce network flakiness in CI.

Copilot uses AI. Check for mistakes.
SELENIUM_PATH=${SELENIUM_HOME}/selenium-server/selenium-server-standalone.jar \
SELENIUM_HTTP_JDK_CLIENT_PATH=${SELENIUM_HOME}/selenium-server/selenium-http-jdk-client.jar \
PATH=${SELENIUM_HOME}/firefox:/opt/google/chrome:${PATH}
PATH=/home/selenium/.local/bin:${SELENIUM_HOME}/firefox:/opt/google/chrome:${PATH}
Copy link

Copilot AI Mar 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PATH is hard-coded to /home/selenium/.local/bin even though SELENIUM_HOME/HOME are already set. This makes the image harder to maintain if SELENIUM_HOME ever changes; prefer deriving the path from SELENIUM_HOME (or HOME) for consistency with the rest of the file.

Suggested change
PATH=/home/selenium/.local/bin:${SELENIUM_HOME}/firefox:/opt/google/chrome:${PATH}
PATH=${SELENIUM_HOME}/.local/bin:${SELENIUM_HOME}/firefox:/opt/google/chrome:${PATH}

Copilot uses AI. Check for mistakes.
RUN --mount=type=bind,src=dist,dst=/dist python3 -m pip install --no-cache-dir --extra server "$(ls -1 /dist/ansible_dev_tools-*)[server]"

# install uv and all supported python versions with it
RUN --mount=type=cache,target=/.cache/uv python3 -m pip install --root-user-action=ignore uv
Copy link

Copilot AI Mar 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The build cache mount --mount=type=cache,target=/.cache/uv is unlikely to be used here: this step runs pip install, which caches under the pip cache dir (typically /root/.cache/pip), and uv itself defaults to ~/.cache/uv (i.e. /root/.cache/uv) unless UV_CACHE_DIR/XDG_CACHE_HOME is set. As written, this can both miss build caching and leave pip caches in the image layer; consider mounting the actual pip/uv cache locations or setting UV_CACHE_DIR to match the mounted path, and/or disabling pip caching for this install.

Suggested change
RUN --mount=type=cache,target=/.cache/uv python3 -m pip install --root-user-action=ignore uv
RUN --mount=type=cache,target=/.cache/uv PIP_CACHE_DIR=/.cache/uv python3 -m pip install --root-user-action=ignore uv

Copilot uses AI. Check for mistakes.

RUN --mount=type=bind,src=dist,dst=/dist python3 -m pip install --no-cache-dir --extra server "$(ls -1 /dist/ansible_dev_tools-*)[server]"

# install uv and all supported python versions with it
Copy link

Copilot AI Mar 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment says "install uv and all supported python versions with it", but this step only installs uv; the Python versions are installed later (after switching to USER 1001). Please update the comment to reflect what happens in this stage to avoid confusion during future maintenance.

Suggested change
# install uv and all supported python versions with it
# install uv package manager (Python versions are installed later as non-root user)

Copilot uses AI. Check for mistakes.

USER 1001
# /home/selenium
RUN uv python install 3.10 3.11 3.12 3.13 3.14
Copy link

Copilot AI Mar 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uv python install 3.10 3.11 3.12 3.13 3.14 introduces a Python 3.14 runtime in the image, but the repo’s declared/tested support appears to stop at 3.13 (e.g. classifiers in pyproject.toml and CI max_python in .github/workflows/tox.yml). To keep a single source of truth for supported versions (and avoid unexpected bloat/build failures if 3.14 isn’t intended), please align this list with the project’s supported versions or document why 3.14 is required here.

Suggested change
RUN uv python install 3.10 3.11 3.12 3.13 3.14
RUN uv python install 3.10 3.11 3.12 3.13

Copilot uses AI. Check for mistakes.
RUN --mount=type=bind,src=dist,dst=/dist python3 -m pip install --no-cache-dir --extra server "$(ls -1 /dist/ansible_dev_tools-*)[server]"

# install uv and all supported python versions with it
RUN --mount=type=cache,target=/.cache/uv python3 -m pip install --root-user-action=ignore uv
Copy link

Copilot AI Mar 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

python3 -m pip install --root-user-action=ignore uv pulls the uv package from PyPI without any version pinning or integrity verification, creating a supply chain risk. An attacker who compromises the uv distribution (or intercepts traffic) could get arbitrary code executed in this image build and at runtime when uv is invoked. Pin uv to a specific, trusted version (and ideally verify its integrity via a hash or lockfile) to ensure builds are deterministic and not exposed to unexpected upstream changes.

Copilot uses AI. Check for mistakes.
@github-actions github-actions bot added chore and removed chore labels Mar 11, 2026
@ssbarnea ssbarnea marked this pull request as draft April 1, 2026 13:35
auto-merge was automatically disabled April 1, 2026 13:35

Pull request was converted to draft

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants