Skip to content

Commit 1e1dcdb

Browse files
authored
NO-JIRA: refactor(jupyter/minimal/Dockerfile.cuda): wrap multiple RUN commands with bash for improved readability and error handling (#2649)
1 parent 9ae4860 commit 1e1dcdb

File tree

1 file changed

+24
-16
lines changed

1 file changed

+24
-16
lines changed

jupyter/minimal/ubi9-python-3.12/Dockerfile.cuda

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,12 @@ EOF
3636
# upgrade first to avoid fixable vulnerabilities end
3737

3838
# Install useful OS packages
39-
RUN dnf install -y perl mesa-libGL skopeo && dnf clean all && rm -rf /var/cache/yum
39+
RUN /bin/bash <<'EOF'
40+
set -Eeuxo pipefail
41+
dnf install -y perl mesa-libGL skopeo
42+
dnf clean all
43+
rm -rf /var/cache/yum
44+
EOF
4045

4146
# Other apps and tools installed as default user
4247
USER 1001
@@ -91,21 +96,24 @@ USER 1001
9196
COPY ${MINIMAL_SOURCE_CODE}/pylock.toml ${MINIMAL_SOURCE_CODE}/start-notebook.sh ./
9297

9398
# Install Python dependencies from requirements.txt file
94-
RUN echo "Installing softwares and packages" && \
95-
# This may have to download and compile some dependencies, and as we don't lock requirements from `build-system.requires`,
96-
# we often don't know the correct hashes and `--require-hashes` would therefore fail on non amd64, where building is common.
97-
uv pip install --strict --no-deps --no-cache --no-config --no-progress --verify-hashes --compile-bytecode --index-strategy=unsafe-best-match --requirements=./pylock.toml && \
98-
# Disable announcement plugin of jupyterlab \
99-
jupyter labextension disable "@jupyterlab/apputils-extension:announcements" && \
100-
# Replace Notebook's launcher, "(ipykernel)" with Python's version 3.x.y \
101-
sed -i -e "s/Python.*/$(python --version | cut -d '.' -f-2)\",/" /opt/app-root/share/jupyter/kernels/python3/kernel.json && \
102-
# copy jupyter configuration
103-
cp /opt/app-root/bin/utils/jupyter_server_config.py /opt/app-root/etc/jupyter && \
104-
# Fix permissions to support pip in Openshift environments \
105-
chmod -R g+w /opt/app-root/lib/python3.12/site-packages && \
106-
fix-permissions /opt/app-root -P && \
107-
# Apply JupyterLab addons \
108-
/opt/app-root/bin/utils/addons/apply.sh
99+
RUN /bin/bash <<'EOF'
100+
set -Eeuxo pipefail
101+
echo "Installing softwares and packages"
102+
# This may have to download and compile some dependencies, and as we don't lock requirements from `build-system.requires`,
103+
# we often don't know the correct hashes and `--require-hashes` would therefore fail on non amd64, where building is common.
104+
uv pip install --strict --no-deps --no-cache --no-config --no-progress --verify-hashes --compile-bytecode --index-strategy=unsafe-best-match --requirements=./pylock.toml
105+
# Disable announcement plugin of jupyterlab
106+
jupyter labextension disable "@jupyterlab/apputils-extension:announcements"
107+
# Replace Notebook's launcher, "(ipykernel)" with Python's version 3.x.y
108+
sed -i -e "s/Python.*/$(python --version | cut -d '.' -f-2)\",/" /opt/app-root/share/jupyter/kernels/python3/kernel.json
109+
# copy jupyter configuration
110+
cp /opt/app-root/bin/utils/jupyter_server_config.py /opt/app-root/etc/jupyter
111+
# Fix permissions to support pip in Openshift environments
112+
chmod -R g+w /opt/app-root/lib/python3.12/site-packages
113+
fix-permissions /opt/app-root -P
114+
# Apply JupyterLab addons
115+
/opt/app-root/bin/utils/addons/apply.sh
116+
EOF
109117

110118
WORKDIR /opt/app-root/src
111119

0 commit comments

Comments
 (0)