Skip to content

Commit ddcab5e

Browse files
RHOAIENG-22962: add code-server python 3.12 image (opendatahub-io#1269)
* copypasta from 3.11 * replace 3.11 to 3.12 * add to Makefile * Update Pipfile.lock files by piplock-renewal.yaml action --------- Co-authored-by: GitHub Actions <github-actions[bot]@users.noreply.github.com>
1 parent 1a14a81 commit ddcab5e

28 files changed

+3372
-4
lines changed

Makefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -416,10 +416,10 @@ else ifeq ($(PYTHON_VERSION), 3.12)
416416
jupyter/datascience/ubi9-python-$(PYTHON_VERSION) \
417417
jupyter/pytorch/ubi9-python-$(PYTHON_VERSION) \
418418
jupyter/tensorflow/ubi9-python-$(PYTHON_VERSION) \
419-
jupyter/rocm/pytorch/ubi9-python-$(PYTHON_VERSION)
419+
jupyter/rocm/pytorch/ubi9-python-$(PYTHON_VERSION) \
420+
codeserver/ubi9-python-$(PYTHON_VERSION)
420421
# jupyter/trustyai/ubi9-python-$(PYTHON_VERSION)
421422
# jupyter/rocm/tensorflow/ubi9-python-$(PYTHON_VERSION)
422-
# codeserver/ubi9-python-$(PYTHON_VERSION)
423423
# runtimes/minimal/ubi9-python-$(PYTHON_VERSION)
424424
# runtimes/datascience/ubi9-python-$(PYTHON_VERSION)
425425
# runtimes/pytorch/ubi9-python-$(PYTHON_VERSION)
@@ -504,13 +504,13 @@ all-images: \
504504
cuda-jupyter-minimal-ubi9-python-$(RELEASE_PYTHON_VERSION) \
505505
cuda-jupyter-tensorflow-ubi9-python-$(RELEASE_PYTHON_VERSION) \
506506
cuda-jupyter-pytorch-ubi9-python-$(RELEASE_PYTHON_VERSION) \
507-
rocm-jupyter-pytorch-ubi9-python-$(RELEASE_PYTHON_VERSION)
507+
rocm-jupyter-pytorch-ubi9-python-$(RELEASE_PYTHON_VERSION) \
508+
codeserver-ubi9-python-$(RELEASE_PYTHON_VERSION)
508509
# jupyter-trustyai-ubi9-python-$(RELEASE_PYTHON_VERSION)
509510
# runtime-minimal-ubi9-python-$(RELEASE_PYTHON_VERSION)
510511
# runtime-datascience-ubi9-python-$(RELEASE_PYTHON_VERSION)
511512
# runtime-cuda-pytorch-ubi9-python-$(RELEASE_PYTHON_VERSION)
512513
# runtime-cuda-tensorflow-ubi9-python-$(RELEASE_PYTHON_VERSION)
513-
# codeserver-ubi9-python-$(RELEASE_PYTHON_VERSION)
514514
# rstudio-c9s-python-$(RELEASE_PYTHON_VERSION)
515515
# cuda-rstudio-c9s-python-$(RELEASE_PYTHON_VERSION)
516516
# rstudio-rhel9-python-$(RELEASE_PYTHON_VERSION)
Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
####################
2+
# base #
3+
####################
4+
FROM registry.access.redhat.com/ubi9/python-312:latest AS base
5+
6+
WORKDIR /opt/app-root/bin
7+
8+
# OS Packages needs to be installed as root
9+
USER 0
10+
11+
# Install useful OS packages
12+
RUN dnf install -y mesa-libGL skopeo && dnf clean all && rm -rf /var/cache/yum
13+
14+
# Other apps and tools installed as default user
15+
USER 1001
16+
17+
# Install micropipenv to deploy packages from Pipfile.lock
18+
RUN pip install --no-cache-dir -U "micropipenv[toml]"
19+
20+
# Install the oc client
21+
RUN curl -L https://mirror.openshift.com/pub/openshift-v4/$(uname -m)/clients/ocp/stable/openshift-client-linux.tar.gz \
22+
-o /tmp/openshift-client-linux.tar.gz && \
23+
tar -xzvf /tmp/openshift-client-linux.tar.gz oc && \
24+
rm -f /tmp/openshift-client-linux.tar.gz
25+
26+
27+
####################
28+
# codeserver #
29+
####################
30+
FROM base AS codeserver
31+
32+
ARG CODESERVER_SOURCE_CODE=codeserver/ubi9-python-3.12
33+
ARG CODESERVER_VERSION=v4.98.0
34+
35+
LABEL name="odh-notebook-code-server-ubi9-python-3.12" \
36+
summary="code-server image with python 3.12 based on UBI 9" \
37+
description="code-server image with python 3.12 based on UBI9" \
38+
io.k8s.display-name="code-server image with python 3.12 based on UBI9" \
39+
io.k8s.description="code-server image with python 3.12 based on UBI9" \
40+
authoritative-source-url="https://github.com/opendatahub-io/notebooks" \
41+
io.openshift.build.commit.ref="main" \
42+
io.openshift.build.source-location="https://github.com/opendatahub-io/notebooks/tree/main/codeserver/ubi9-python-3.12" \
43+
io.openshift.build.image="quay.io/opendatahub/workbench-images:codeserver-ubi9-python-3.12"
44+
45+
USER 0
46+
47+
WORKDIR /opt/app-root/bin
48+
49+
# Install usefull OS packages
50+
RUN dnf install -y jq git-lfs libsndfile && dnf clean all && rm -rf /var/cache/yum
51+
52+
# Install code-server
53+
RUN yum install -y "https://github.com/coder/code-server/releases/download/${CODESERVER_VERSION}/code-server-${CODESERVER_VERSION/v/}-amd64.rpm" && \
54+
yum -y clean all --enablerepo='*'
55+
56+
COPY --chown=1001:0 ${CODESERVER_SOURCE_CODE}/utils utils/
57+
58+
# Create and intall the extensions though build-time on a temporary directory. Later this directory will copied on the `/opt/app-root/src/.local/share/code-server/extensions` via run-code-server.sh file when it starts up.
59+
RUN mkdir -p /opt/app-root/extensions-temp && \
60+
code-server --install-extension /opt/app-root/bin/utils/ms-python.python-2025.2.0.vsix --extensions-dir /opt/app-root/extensions-temp && \
61+
code-server --install-extension /opt/app-root/bin/utils/ms-toolsai.jupyter-2025.2.0.vsix --extensions-dir /opt/app-root/extensions-temp
62+
63+
# Install NGINX to proxy code-server and pass probes check
64+
ENV NGINX_VERSION=1.24 \
65+
NGINX_SHORT_VER=124 \
66+
NGINX_CONFIGURATION_PATH=${APP_ROOT}/etc/nginx.d \
67+
NGINX_CONF_PATH=/etc/nginx/nginx.conf \
68+
NGINX_DEFAULT_CONF_PATH=${APP_ROOT}/etc/nginx.default.d \
69+
NGINX_CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/nginx \
70+
NGINX_APP_ROOT=${APP_ROOT} \
71+
NGINX_LOG_PATH=/var/log/nginx \
72+
NGINX_PERL_MODULE_PATH=${APP_ROOT}/etc/perl
73+
74+
# Modules does not exist
75+
RUN yum install -y https://download.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm && \
76+
INSTALL_PKGS="bind-utils nginx nginx-mod-stream nginx-mod-http-perl fcgiwrap initscripts chkconfig supervisor" && \
77+
yum install -y --setopt=tsflags=nodocs $INSTALL_PKGS && \
78+
rpm -V $INSTALL_PKGS && \
79+
yum -y clean all --enablerepo='*'
80+
81+
COPY --chown=1001:0 ${CODESERVER_SOURCE_CODE}/supervisord/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
82+
83+
# Copy extra files to the image.
84+
COPY --chown=1001:0 ${CODESERVER_SOURCE_CODE}/nginx/root/ /
85+
86+
# Changing ownership and user rights to support following use-cases:
87+
# 1) running container on OpenShift, whose default security model
88+
# is to run the container under random UID, but GID=0
89+
# 2) for working root-less container with UID=1001, which does not have
90+
# to have GID=0
91+
# 3) for default use-case, that is running container directly on operating system,
92+
# with default UID and GID (1001:0)
93+
# Supported combinations of UID:GID are thus following:
94+
# UID=1001 && GID=0
95+
# UID=<any>&& GID=0
96+
# UID=1001 && GID=<any>
97+
RUN sed -i -f ${NGINX_APP_ROOT}/nginxconf.sed ${NGINX_CONF_PATH} && \
98+
mkdir -p ${NGINX_APP_ROOT}/etc/nginx.d/ && \
99+
mkdir -p ${NGINX_APP_ROOT}/etc/nginx.default.d/ && \
100+
mkdir -p ${NGINX_APP_ROOT}/api/ && \
101+
mkdir -p ${NGINX_CONTAINER_SCRIPTS_PATH}/nginx-start && \
102+
mkdir -p ${NGINX_LOG_PATH} && \
103+
mkdir -p ${NGINX_PERL_MODULE_PATH} && \
104+
chown -R 1001:0 ${NGINX_CONF_PATH} && \
105+
chown -R 1001:0 ${NGINX_APP_ROOT}/etc && \
106+
chown -R 1001:0 ${NGINX_CONTAINER_SCRIPTS_PATH}/nginx-start && \
107+
chown -R 1001:0 /var/lib/nginx /var/log/nginx /run && \
108+
chmod ug+rw ${NGINX_CONF_PATH} && \
109+
chmod -R ug+rwX ${NGINX_APP_ROOT}/etc && \
110+
chmod -R ug+rwX ${NGINX_CONTAINER_SCRIPTS_PATH}/nginx-start && \
111+
chmod -R ug+rwX /var/lib/nginx /var/log/nginx /run && \
112+
rpm-file-permissions && \
113+
# Ensure the temporary directory and target directory have the correct permissions
114+
mkdir -p /opt/app-root/src/.local/share/code-server/extensions && \
115+
mkdir -p /opt/app-root/src/.local/share/code-server/coder-logs && \
116+
chown -R 1001:0 /opt/app-root/src/.local/share/code-server && \
117+
chown -R 1001:0 /opt/app-root/extensions-temp && \
118+
chown -R 1001:0 /opt/app-root/src/.config/code-server
119+
120+
## Configure nginx
121+
COPY ${CODESERVER_SOURCE_CODE}/nginx/serverconf/ /opt/app-root/etc/nginx.default.d/
122+
COPY ${CODESERVER_SOURCE_CODE}/nginx/httpconf/ /opt/app-root/etc/nginx.d/
123+
COPY ${CODESERVER_SOURCE_CODE}/nginx/api/ /opt/app-root/api/
124+
125+
# Launcher
126+
COPY --chown=1001:0 ${CODESERVER_SOURCE_CODE}/run-code-server.sh ${CODESERVER_SOURCE_CODE}/run-nginx.sh ./
127+
128+
ENV SHELL=/bin/bash
129+
130+
ENV PYTHONPATH=/opt/app-root/bin/python3
131+
132+
USER 1001
133+
134+
# Install usefull packages from Pipfile.lock
135+
COPY ${CODESERVER_SOURCE_CODE}/Pipfile.lock ./
136+
137+
# Install packages and cleanup
138+
RUN echo "Installing softwares and packages" && \
139+
micropipenv install && \
140+
rm -f ./Pipfile.lock && \
141+
# Fix permissions to support pip in Openshift environments \
142+
chmod -R g+w /opt/app-root/lib/python3.12/site-packages && \
143+
fix-permissions /opt/app-root -P
144+
145+
WORKDIR /opt/app-root/src
146+
147+
CMD ["/opt/app-root/bin/run-code-server.sh"]

codeserver/ubi9-python-3.12/Pipfile

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
[[source]]
2+
name = "pypi"
3+
url = "https://pypi.org/simple"
4+
verify_ssl = true
5+
6+
[[source]]
7+
name = "pytorch"
8+
url = "https://download.pytorch.org/whl/cu118"
9+
verify_ssl = true
10+
11+
[dev-packages]
12+
13+
[packages]
14+
# Base packages
15+
wheel = "~=0.45.1"
16+
setuptools = "~=78.1.1"
17+
18+
# Datascience packages
19+
boto3 = "~=1.37.8"
20+
kafka-python-ng = "~=2.2.3"
21+
matplotlib = "~=3.10.1"
22+
numpy = "~=2.2.3"
23+
pandas = "~=2.2.3"
24+
plotly = "~=6.0.0"
25+
scikit-learn = "~=1.6.1"
26+
scipy = "~=1.15.2"
27+
skl2onnx = "~=1.18.0"
28+
ipykernel = "~=6.29.5"
29+
kubeflow-training = "==1.9.2"
30+
31+
# Some extra useful packages
32+
opencensus = "~=0.11.4"
33+
smart-open = "~=7.0.1"
34+
virtualenv = "~=20.29.3"
35+
py-spy = "~=0.4.0"
36+
prometheus-client = "~=0.21.1"
37+
38+
[requires]
39+
python_version = "3.12"

0 commit comments

Comments
 (0)