@@ -15,6 +15,27 @@ RUN curl -Lo mongodb-cli-mongocli-v${MONGOCLI_VERSION}.zip https://github.com/mo
1515RUN unzip ./mongodb-cli-mongocli-v${MONGOCLI_VERSION}.zip
1616RUN cd ./mongodb-cli-mongocli-v${MONGOCLI_VERSION}/ && \
1717 CGO_ENABLED=1 GOOS=linux go build -a -tags strictfipsruntime -o /tmp/mongocli ./cmd/mongocli/
18+ ####################
19+ # wheel-cache-base #
20+ ####################
21+ FROM ${BASE_IMAGE} AS whl-cache
22+
23+ USER root
24+ ENV HOME=/root
25+ WORKDIR /root
26+
27+ ARG TRUSTYAI_SOURCE_CODE=jupyter/trustyai/ubi9-python-3.12
28+
29+ COPY ${TRUSTYAI_SOURCE_CODE}/pylock.toml .
30+ COPY ${TRUSTYAI_SOURCE_CODE}/devel_env_setup.sh .
31+
32+ RUN --mount=type=cache,target=/root/.cache/uv \
33+ pip install --no-cache uv && \
34+ # the devel script is ppc64le specific - sets up build-time dependencies
35+ source ./devel_env_setup.sh && \
36+ # This may have to download and compile some dependencies, and as we don't lock requirements from `build-system.requires`,
37+ # we often don't know the correct hashes and `--require-hashes` would therefore fail on non amd64, where building is common.
38+ UV_LINK_MODE=copy uv pip install --strict --no-deps --refresh --no-config --no-progress --verify-hashes --compile-bytecode --index-strategy=unsafe-best-match --requirements=./pylock.toml
1839
1940####################
2041# cpu-base #
@@ -117,6 +138,8 @@ FROM jupyter-datascience AS jupyter-trustyai
117138ARG DATASCIENCE_SOURCE_CODE=jupyter/datascience/ubi9-python-3.12
118139ARG TRUSTYAI_SOURCE_CODE=jupyter/trustyai/ubi9-python-3.12
119140
141+ ENV LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib
142+
120143LABEL name="odh-notebook-jupyter-trustyai-ubi9-python-3.12" \
121144 summary="Jupyter trustyai notebook image for ODH notebooks" \
122145 description="Jupyter trustyai notebook image with base Python 3.12 builder image based on UBI9 for ODH notebooks" \
@@ -134,16 +157,39 @@ RUN INSTALL_PKGS="java-17-openjdk" && \
134157 dnf install -y --setopt=tsflags=nodocs $INSTALL_PKGS && \
135158 dnf -y clean all --enablerepo='*'
136159
137- USER 1001
138-
139160# Install Python packages and Jupyterlab extensions from requirements.txt
140161COPY ${TRUSTYAI_SOURCE_CODE}/pylock.toml ./
141162
142- RUN echo "Installing softwares and packages" && \
143- # This may have to download and compile some dependencies, and as we don't lock requirements from `build-system.requires`,
144- # we often don't know the correct hashes and `--require-hashes` would therefore fail on non amd64, where building is common.
145- uv pip install --strict --no-deps --no-cache --no-config --no-progress --verify-hashes --compile-bytecode --index-strategy=unsafe-best-match --requirements=./pylock.toml && \
146- # setup path for runtime configuration
163+ # install openblas for ppc64le
164+ RUN --mount=type=cache,from=whl-cache,source=/root/OpenBLAS/,target=/OpenBlas/,rw \
165+ bash -c ' \
166+ if [[ $(uname -m) == "ppc64le" ]]; then \
167+ dnf install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm; \
168+ dnf install -y libraqm libimagequant; \
169+ PREFIX=/usr/ make install -C /OpenBlas; \
170+ fi '
171+
172+ # Install packages and cleanup
173+ # install packages as USER 0 (this will allow us to consume uv cache)
174+ RUN --mount=type=cache,from=whl-cache,source=/wheelsdir/,target=/wheelsdir/,rw \
175+ --mount=type=cache,target=/root/.cache/uv \
176+ bash -c ' \
177+ if [[ $(uname -m) == "ppc64le" ]]; then \
178+ UV_LINK_MODE=copy uv pip install /wheelsdir/*.whl accelerate --cache-dir /root/.cache/uv; \
179+ fi '
180+ RUN --mount=type=cache,target=/root/.cache/uv \
181+ echo "Installing softwares and packages" && \
182+ # we can ensure wheels are consumed from the cache only by restricting internet access for uv install with '--offline' flag
183+ UV_LINK_MODE=copy uv pip install --cache-dir /root/.cache/uv --requirements=./pylock.toml && \
184+ # Note: debugpy wheel availabe on pypi (in uv cache) is none-any but bundles amd64.so files
185+ # Build debugpy from source instead
186+ UV_LINK_MODE=copy uv pip install --no-cache git+https://github.com/microsoft/debugpy.git@v$(grep -A1 '\"debugpy\"' ./pylock.toml | grep -Eo '\b[0-9\.]+\b') && \
187+ # change ownership to default user (all packages were installed as root and has root:root ownership \
188+ chown -R 1001:0 /opt/app-root/
189+
190+ USER 1001
191+
192+ RUN # setup path for runtime configuration \
147193 mkdir /opt/app-root/runtimes && \
148194 # Remove default Elyra runtime-images \
149195 rm /opt/app-root/share/jupyter/metadata/runtime-images/*.json && \
0 commit comments