1+ #########################
2+ # configuration args #
3+ #########################
4+ ARG BASE_IMAGE
5+
16# External image alias for UBI repository configuration
27FROM registry.access.redhat.com/ubi9/ubi AS ubi-repos
38
4- FROM quay.io/aipcc/base-images/cpu:3.0-1761652019 AS cpu-base
9+ ############################
10+ # Stage 1: PDF Tool Build #
11+ ############################
12+ FROM registry.access.redhat.com/ubi9/python-312:latest AS pdf-builder
13+
14+ WORKDIR /opt/app-root/bin
515
616# OS Packages needs to be installed as root
717USER 0
818
9- RUN subscription-manager register --org "$(cat /activation-key/org)" --activationkey "$(cat /activation-key/activationkey)"
19+ # Copy scripts
20+ COPY jupyter/utils/install_texlive.sh ./install_texlive.sh
21+ COPY jupyter/utils/install_pandoc.sh ./install_pandoc.sh
22+ RUN chmod +x install_texlive.sh install_pandoc.sh
23+
24+ RUN ./install_texlive.sh
25+ RUN ./install_pandoc.sh
26+
27+ ####################
28+ # cpu-base #
29+ ####################
30+ FROM ${BASE_IMAGE} AS cpu-base
31+ USER 0
32+ RUN subscription-manager refresh
33+
34+ WORKDIR /opt/app-root/bin
35+
36+ # OS Packages needs to be installed as root
37+ USER 0
1038
1139# Inject the official UBI 9 repository configuration into the AIPCC base image.
1240# The Quay-based AIPCC image is "repo-less" by default (https://gitlab.com/redhat/rhel-ai/core/base-images/app#repositories), so dnf cannot upgrade or install packages.
@@ -24,4 +52,73 @@ RUN dnf -y upgrade --refresh --nobest --skip-broken --nodocs --noplugins --setop
2452# Install useful OS packages
2553RUN dnf install -y perl mesa-libGL skopeo && dnf clean all && rm -rf /var/cache/yum
2654
55+ # Other apps and tools installed as default user
2756USER 1001
57+
58+ # Install micropipenv and uv to deploy packages from requirements.txt begin
59+ RUN pip install --no-cache-dir -U "micropipenv[toml]==1.9.0" "uv==0.8.12"
60+ # Install micropipenv and uv to deploy packages from requirements.txt end
61+
62+ # Install the oc client begin
63+ RUN curl -L https://mirror.openshift.com/pub/openshift-v4/$(uname -m)/clients/ocp/stable/openshift-client-linux.tar.gz \
64+ -o /tmp/openshift-client-linux.tar.gz && \
65+ tar -xzvf /tmp/openshift-client-linux.tar.gz oc && \
66+ rm -f /tmp/openshift-client-linux.tar.gz
67+ # Install the oc client end
68+
69+ ####################
70+ # jupyter-minimal #
71+ ####################
72+ FROM cpu-base AS jupyter-minimal
73+
74+ ARG JUPYTER_REUSABLE_UTILS=jupyter/utils
75+ ARG MINIMAL_SOURCE_CODE=jupyter/minimal/ubi9-python-3.12
76+
77+ WORKDIR /opt/app-root/bin
78+
79+ COPY ${JUPYTER_REUSABLE_UTILS} utils/
80+
81+ USER 0
82+
83+ # Dependencies for PDF export begin
84+ RUN --mount=type=cache,from=pdf-builder,source=/usr/local/,target=/pdf_builder/,rw \
85+ bash -c ' \
86+ if [[ "$(uname -m)" == "ppc64le" ]]; then \
87+ cp -r /pdf_builder/texlive /usr/local/; \
88+ cp -r /pdf_builder/pandoc /usr/local/; \
89+ else \
90+ ./utils/install_pdf_deps.sh; \
91+ fi'
92+
93+ USER 1001
94+
95+ COPY ${MINIMAL_SOURCE_CODE}/pylock.toml ${MINIMAL_SOURCE_CODE}/start-notebook.sh ./
96+
97+ # Install Python dependencies from requirements.txt file
98+ RUN echo "Installing softwares and packages" && \
99+ # This may have to download and compile some dependencies, and as we don't lock requirements from `build-system.requires`,
100+ # we often don't know the correct hashes and `--require-hashes` would therefore fail on non amd64, where building is common.
101+ uv pip install --strict --no-deps --no-cache --no-config --no-progress --verify-hashes --compile-bytecode --index-strategy=unsafe-best-match --requirements=./pylock.toml && \
102+ # Disable announcement plugin of jupyterlab \
103+ jupyter labextension disable "@jupyterlab/apputils-extension:announcements" && \
104+ # Replace Notebook's launcher, "(ipykernel)" with Python's version 3.x.y \
105+ sed -i -e "s/Python.*/$(python --version | cut -d '.' -f-2)\",/" /opt/app-root/share/jupyter/kernels/python3/kernel.json && \
106+ # copy jupyter configuration
107+ cp /opt/app-root/bin/utils/jupyter_server_config.py /opt/app-root/etc/jupyter && \
108+ # Fix permissions to support pip in Openshift environments \
109+ chmod -R g+w /opt/app-root/lib/python3.12/site-packages && \
110+ fix-permissions /opt/app-root -P && \
111+ # Apply JupyterLab addons \
112+ /opt/app-root/bin/utils/addons/apply.sh
113+
114+ WORKDIR /opt/app-root/src
115+
116+ ENTRYPOINT ["start-notebook.sh"]
117+
118+ LABEL name="rhoai/odh-workbench-jupyter-minimal-cpu-py312-rhel9" \
119+ com.redhat.component="odh-workbench-jupyter-minimal-cpu-py312-rhel9" \
120+ io.k8s.display-name="odh-workbench-jupyter-minimal-cpu-py312-rhel9" \
121+ summary="Minimal Jupyter CPU notebook image for ODH notebooks" \
122+ description="Minimal Jupyter CPU notebook image with base Python 3.12 builder image based on UBI9 for ODH notebooks" \
123+ io.k8s.description="Minimal Jupyter CPU notebook image with base Python 3.12 builder image based on UBI9 for ODH notebooks" \
124+ com.redhat.license_terms="https://www.redhat.com/licenses/Red_Hat_Standard_EULA_20191108.pdf"
0 commit comments