From 755f98a33814bd9a850526b45734ea0a4bbc5568 Mon Sep 17 00:00:00 2001 From: kingbri <8082010+kingbri1@users.noreply.github.com> Date: Sun, 27 Apr 2025 00:38:07 -0400 Subject: [PATCH] Docker: Move to venv for running Newer versions of Python don't allow system package installation unless --break-system-packages are specified. I'd like to avoid this if possible. Signed-off-by: kingbri <8082010+kingbri1@users.noreply.github.com> --- docker/Dockerfile | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 2113e37..705d76f 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -8,10 +8,17 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ ca-certificates \ python3.12 \ python3-pip \ + python3.12-venv \ && rm -rf /var/lib/apt/lists/* +# Create a virtual environment +RUN python3 -m venv /opt/venv + +# Activate the venv and set the PATH +ENV PATH="/opt/venv/bin:$PATH" + # Upgrade pip -RUN pip3 install --no-cache-dir --upgrade pip +RUN pip install --no-cache-dir --upgrade pip # Set the working directory in the container WORKDIR /app @@ -20,7 +27,7 @@ WORKDIR /app COPY pyproject.toml . # Install packages specified in pyproject.toml cu121, extras -RUN pip3 install --no-cache-dir .[cu121,extras] +RUN pip install --no-cache-dir .[cu121,extras] RUN rm pyproject.toml