Skip to content

Docker: Setup Python venv in Base image for utilities #2748

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 25 additions & 7 deletions Base/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@ ARG VERSION
ARG RELEASE=selenium-${VERSION}
ARG MVN_SELENIUM_VERSION
# Default value should be aligned with upstream Selenium (https://github.com/SeleniumHQ/selenium/blob/trunk/MODULE.bazel)
ARG OPENTELEMETRY_VERSION=1.46.0
ARG GRPC_VERSION=1.70.0
ARG NETTY_VERSION=4.1.118.Final
ARG OPENTELEMETRY_VERSION=1.48.0
ARG GRPC_VERSION=1.71.0
ARG CS_VERSION=2.1.18
ARG POSTGRESQL_VERSION=42.7.5
ARG ENVSUBST_VERSION=1.4.3
Expand Down Expand Up @@ -61,13 +60,35 @@ RUN apt-get -qqy update \
unzip \
wget \
jq \
supervisor \
gnupg2 \
libnss3-tools \
openjdk-${JRE_VERSION}-jdk-headless \
ca-certificates \
&& rm -rf /var/lib/apt/lists/* /var/cache/apt/*

#========================================
# Install Python for utilities
#========================================
RUN apt-get -qqy update \
&& apt-get upgrade -yq \
&& apt-get -qqy --no-install-recommends install \
python3 python3-pip python3-venv python3-setuptools \
&& rm -rf /var/lib/apt/lists/* /var/cache/apt/*

ENV VENV_PATH=/opt/venv
RUN python3 -m venv $VENV_PATH \
echo "source $VENV_PATH/bin/activate" >> /etc/bash.bashrc

RUN $VENV_PATH/bin/python3 -m pip install --upgrade pip setuptools virtualenv psutil \
&& wget -q https://github.com/Supervisor/supervisor/archive/refs/heads/main.zip -O /tmp/supervisor.zip \
&& unzip /tmp/supervisor.zip -d /tmp \
&& cd /tmp/supervisor-main \
&& $VENV_PATH/bin/python3 -m pip install --break-system-packages . \
&& rm -rf /tmp/supervisor.zip /tmp/supervisor-main

ENV PATH="$VENV_PATH/bin:$PATH" \
VIRTUAL_ENV="$VENV_PATH"

RUN ARCH=$(if [ "$(dpkg --print-architecture)" = "arm64" ]; then echo "aarch64"; else echo "$(dpkg --print-architecture)"; fi) \
&& wget -q https://github.com/moparisthebest/static-curl/releases/download/v8.11.0/curl-$ARCH -O /usr/bin/curl \
&& chmod +x /usr/bin/curl \
Expand Down Expand Up @@ -130,9 +151,6 @@ RUN --mount=type=secret,id=SEL_PASSWD \
java -jar /tmp/cs fetch --classpath --cache /external_jars \
io.opentelemetry:opentelemetry-exporter-otlp:${OPENTELEMETRY_VERSION} \
io.grpc:grpc-netty:${GRPC_VERSION} \
io.netty:netty-codec-http:${NETTY_VERSION} \
io.netty:netty-handler:${NETTY_VERSION} \
io.netty:netty-common:${NETTY_VERSION} \
> /external_jars/.classpath.txt \
&& chmod 664 /external_jars/.classpath.txt \
&& java -jar /tmp/cs fetch --classpath --cache /external_jars \
Expand Down
8 changes: 7 additions & 1 deletion Base/entry_point.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,13 @@ if ! whoami &>/dev/null; then
fi
fi

/usr/bin/supervisord --configuration /etc/supervisord.conf &
if [ -n "${VIRTUAL_ENV}" ]; then
echo "Virtual environment detected at ${VIRTUAL_ENV}, activating..."
source ${VIRTUAL_ENV}/bin/activate
python3 --version
fi

supervisord --configuration /etc/supervisord.conf &

SUPERVISOR_PID=$!

Expand Down
2 changes: 1 addition & 1 deletion NodeBase/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ RUN --mount=type=secret,id=SEL_PASSWD \
&& rm websockify.zip \
# Setup dependencies
&& cd websockify-${WEBSOCKIFY_VERSION#v} \
&& python3 -m pip install --break-system-packages . \
&& $VENV_PATH/bin/python3 -m pip install --break-system-packages . \
# Move websockify and run to the noVNC directory
&& mv websockify /opt/bin/noVNC/utils/websockify \
&& mv run /opt/bin/noVNC/utils/websockify \
Expand Down
2 changes: 0 additions & 2 deletions Video/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,8 @@ RUN apt-get -qqy update \
&& apt-get -qqy --no-install-recommends install \
libx11-6 libx11-xcb1 libxcb1 libpulse0 libasound2t64 \
x11-xserver-utils x11-utils \
python3-pip \
&& apt-get -qqy update \
&& apt-get -yq upgrade \
&& pip install --upgrade --break-system-packages --no-cache-dir setuptools psutil \
&& rm -rf /var/lib/apt/lists/* /var/cache/apt/*

COPY *.conf /etc/supervisor/conf.d/
Expand Down
8 changes: 7 additions & 1 deletion Video/entry_point.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,13 @@ if ! whoami &>/dev/null; then
fi
fi

/usr/bin/supervisord --configuration /etc/supervisord.conf &
if [ -n "${VIRTUAL_ENV}" ]; then
echo "Virtual environment detected at ${VIRTUAL_ENV}, activating..."
source ${VIRTUAL_ENV}/bin/activate
python3 --version
fi

supervisord --configuration /etc/supervisord.conf &

SUPERVISOR_PID=$!

Expand Down
Loading