Skip to content

Commit 5c0402b

Browse files
authored
Docker: Setup Python venv in Base image for utilities (#2748)
Signed-off-by: Viet Nguyen Duc <[email protected]>
1 parent 26c45cd commit 5c0402b

File tree

5 files changed

+40
-12
lines changed

5 files changed

+40
-12
lines changed

Base/Dockerfile

+25-7
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,8 @@ ARG VERSION
88
ARG RELEASE=selenium-${VERSION}
99
ARG MVN_SELENIUM_VERSION
1010
# Default value should be aligned with upstream Selenium (https://github.com/SeleniumHQ/selenium/blob/trunk/MODULE.bazel)
11-
ARG OPENTELEMETRY_VERSION=1.46.0
12-
ARG GRPC_VERSION=1.70.0
13-
ARG NETTY_VERSION=4.1.118.Final
11+
ARG OPENTELEMETRY_VERSION=1.48.0
12+
ARG GRPC_VERSION=1.71.0
1413
ARG CS_VERSION=2.1.18
1514
ARG POSTGRESQL_VERSION=42.7.5
1615
ARG ENVSUBST_VERSION=1.4.3
@@ -61,13 +60,35 @@ RUN apt-get -qqy update \
6160
unzip \
6261
wget \
6362
jq \
64-
supervisor \
6563
gnupg2 \
6664
libnss3-tools \
6765
openjdk-${JRE_VERSION}-jdk-headless \
6866
ca-certificates \
6967
&& rm -rf /var/lib/apt/lists/* /var/cache/apt/*
7068

69+
#========================================
70+
# Install Python for utilities
71+
#========================================
72+
RUN apt-get -qqy update \
73+
&& apt-get upgrade -yq \
74+
&& apt-get -qqy --no-install-recommends install \
75+
python3 python3-pip python3-venv python3-setuptools \
76+
&& rm -rf /var/lib/apt/lists/* /var/cache/apt/*
77+
78+
ENV VENV_PATH=/opt/venv
79+
RUN python3 -m venv $VENV_PATH \
80+
echo "source $VENV_PATH/bin/activate" >> /etc/bash.bashrc
81+
82+
RUN $VENV_PATH/bin/python3 -m pip install --upgrade pip setuptools virtualenv psutil \
83+
&& wget -q https://github.com/Supervisor/supervisor/archive/refs/heads/main.zip -O /tmp/supervisor.zip \
84+
&& unzip /tmp/supervisor.zip -d /tmp \
85+
&& cd /tmp/supervisor-main \
86+
&& $VENV_PATH/bin/python3 -m pip install --break-system-packages . \
87+
&& rm -rf /tmp/supervisor.zip /tmp/supervisor-main
88+
89+
ENV PATH="$VENV_PATH/bin:$PATH" \
90+
VIRTUAL_ENV="$VENV_PATH"
91+
7192
RUN ARCH=$(if [ "$(dpkg --print-architecture)" = "arm64" ]; then echo "aarch64"; else echo "$(dpkg --print-architecture)"; fi) \
7293
&& wget -q https://github.com/moparisthebest/static-curl/releases/download/v8.11.0/curl-$ARCH -O /usr/bin/curl \
7394
&& chmod +x /usr/bin/curl \
@@ -130,9 +151,6 @@ RUN --mount=type=secret,id=SEL_PASSWD \
130151
java -jar /tmp/cs fetch --classpath --cache /external_jars \
131152
io.opentelemetry:opentelemetry-exporter-otlp:${OPENTELEMETRY_VERSION} \
132153
io.grpc:grpc-netty:${GRPC_VERSION} \
133-
io.netty:netty-codec-http:${NETTY_VERSION} \
134-
io.netty:netty-handler:${NETTY_VERSION} \
135-
io.netty:netty-common:${NETTY_VERSION} \
136154
> /external_jars/.classpath.txt \
137155
&& chmod 664 /external_jars/.classpath.txt \
138156
&& java -jar /tmp/cs fetch --classpath --cache /external_jars \

Base/entry_point.sh

+7-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,13 @@ if ! whoami &>/dev/null; then
1212
fi
1313
fi
1414

15-
/usr/bin/supervisord --configuration /etc/supervisord.conf &
15+
if [ -n "${VIRTUAL_ENV}" ]; then
16+
echo "Virtual environment detected at ${VIRTUAL_ENV}, activating..."
17+
source ${VIRTUAL_ENV}/bin/activate
18+
python3 --version
19+
fi
20+
21+
supervisord --configuration /etc/supervisord.conf &
1622

1723
SUPERVISOR_PID=$!
1824

NodeBase/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ RUN --mount=type=secret,id=SEL_PASSWD \
133133
&& rm websockify.zip \
134134
# Setup dependencies
135135
&& cd websockify-${WEBSOCKIFY_VERSION#v} \
136-
&& python3 -m pip install --break-system-packages . \
136+
&& $VENV_PATH/bin/python3 -m pip install --break-system-packages . \
137137
# Move websockify and run to the noVNC directory
138138
&& mv websockify /opt/bin/noVNC/utils/websockify \
139139
&& mv run /opt/bin/noVNC/utils/websockify \

Video/Dockerfile

-2
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,8 @@ RUN apt-get -qqy update \
1919
&& apt-get -qqy --no-install-recommends install \
2020
libx11-6 libx11-xcb1 libxcb1 libpulse0 libasound2t64 \
2121
x11-xserver-utils x11-utils \
22-
python3-pip \
2322
&& apt-get -qqy update \
2423
&& apt-get -yq upgrade \
25-
&& pip install --upgrade --break-system-packages --no-cache-dir setuptools psutil \
2624
&& rm -rf /var/lib/apt/lists/* /var/cache/apt/*
2725

2826
COPY *.conf /etc/supervisor/conf.d/

Video/entry_point.sh

+7-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,13 @@ if ! whoami &>/dev/null; then
1010
fi
1111
fi
1212

13-
/usr/bin/supervisord --configuration /etc/supervisord.conf &
13+
if [ -n "${VIRTUAL_ENV}" ]; then
14+
echo "Virtual environment detected at ${VIRTUAL_ENV}, activating..."
15+
source ${VIRTUAL_ENV}/bin/activate
16+
python3 --version
17+
fi
18+
19+
supervisord --configuration /etc/supervisord.conf &
1420

1521
SUPERVISOR_PID=$!
1622

0 commit comments

Comments
 (0)