Skip to content

Commit fcee493

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

File tree

1 file changed

+24
-16
lines changed

1 file changed

+24
-16
lines changed

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

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

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

3944
# Other apps and tools installed as default user
4045
USER 1001
@@ -89,21 +94,24 @@ USER 1001
8994
COPY ${MINIMAL_SOURCE_CODE}/pylock.toml ${MINIMAL_SOURCE_CODE}/start-notebook.sh ./
9095

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

108116
WORKDIR /opt/app-root/src
109117

0 commit comments

Comments
 (0)