Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions codeserver/ubi9-python-3.12/Dockerfile.cpu
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ ARG NODE_VERSION=22.18.0
ARG CODESERVER_VERSION=v4.104.0

COPY ${CODESERVER_SOURCE_CODE}/get_code_server_rpm.sh .
COPY --chown=1001:0 ${CODESERVER_SOURCE_CODE}/utils utils/

# create dummy file to ensure this stage is awaited before installing rpm
RUN ./get_code_server_rpm.sh && touch /tmp/control
Expand Down Expand Up @@ -66,6 +67,8 @@ RUN touch /tmp/control
####################
FROM ${BASE_IMAGE} AS cpu-base

ARG CODESERVER_SOURCE_CODE=codeserver/ubi9-python-3.12

WORKDIR /opt/app-root/bin

# OS Packages needs to be installed as root
Expand All @@ -85,7 +88,8 @@ RUN dnf -y upgrade --refresh --nobest --skip-broken --nodocs --noplugins --setop
# upgrade first to avoid fixable vulnerabilities end

# Install useful OS packages
RUN dnf install -y perl mesa-libGL skopeo && dnf clean all && rm -rf /var/cache/yum
COPY --chown=1001:0 ${CODESERVER_SOURCE_CODE}/utils utils/
RUN --mount=type=cache,target=/var/cache/dnf ./utils/install_with_retry.sh dnf-install perl mesa-libGL skopeo

# (ARCH-ppc64le): since wheels are compiled from source, we need shared libs available at runtime
RUN --mount=type=cache,from=whl-cache,source=/root/OpenBLAS,target=/OpenBlas,rw \
Expand Down Expand Up @@ -136,7 +140,7 @@ USER 0
WORKDIR /opt/app-root/bin

# Install useful OS packages
RUN dnf install -y jq git-lfs libsndfile && dnf clean all && rm -rf /var/cache/yum
RUN --mount=type=cache,target=/var/cache/dnf ./utils/install_with_retry.sh dnf-install jq git-lfs libsndfile

# wait for rpm-base stage (rpm builds for ppc64le)
COPY --from=rpm-base /tmp/control /dev/null
Expand All @@ -152,8 +156,6 @@ RUN --mount=type=cache,from=rpm-base,source=/tmp/,target=/code-server-rpm/,rw \
dnf install -y cpio && dnf -y clean all && \
cd / && rpm2cpio "/code-server-rpm/code-server-${CODESERVER_VERSION/v/}-${TARGETARCH}.rpm" | cpio -idmv

COPY --chown=1001:0 ${CODESERVER_SOURCE_CODE}/utils utils/

# 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.
# https://coder.com/docs/code-server/FAQ#how-do-i-install-an-extension
RUN mkdir -p /opt/app-root/extensions-temp && \
Expand All @@ -175,10 +177,10 @@ ENV NGINX_CONFIGURATION_PATH=${APP_ROOT}/etc/nginx.d \
NGINX_PERL_MODULE_PATH=${APP_ROOT}/etc/perl

# Modules does not exist
RUN INSTALL_PKGS="bind-utils nginx nginx-mod-stream nginx-mod-http-perl httpd" && \
dnf install -y --setopt=tsflags=nodocs $INSTALL_PKGS && \
rpm -V $INSTALL_PKGS && \
dnf -y clean all --enablerepo='*'
RUN --mount=type=cache,target=/var/cache/dnf \
DNF_EXTRA_OPTS="--setopt=tsflags=nodocs" ./utils/install_with_retry.sh dnf-install bind-utils nginx nginx-mod-stream nginx-mod-http-perl httpd \
&& rpm -V bind-utils nginx nginx-mod-stream nginx-mod-http-perl httpd \
&& dnf -y clean all --enablerepo='*'

# Configure httpd for CGI processing
COPY --chown=1001:0 ${CODESERVER_SOURCE_CODE}/httpd/httpd.conf /etc/httpd/conf/httpd.conf
Expand Down
16 changes: 10 additions & 6 deletions codeserver/ubi9-python-3.12/Dockerfile.konflux.cpu
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ ARG NODE_VERSION=22.18.0
ARG CODESERVER_VERSION=v4.104.0

COPY ${CODESERVER_SOURCE_CODE}/get_code_server_rpm.sh .
COPY --chown=1001:0 ${CODESERVER_SOURCE_CODE}/utils utils/

# create dummy file to ensure this stage is awaited before installing rpm
RUN ./get_code_server_rpm.sh && touch /tmp/control
Expand Down Expand Up @@ -66,6 +67,8 @@ RUN touch /tmp/control
####################
FROM ${BASE_IMAGE} AS cpu-base

ARG CODESERVER_SOURCE_CODE=codeserver/ubi9-python-3.12

WORKDIR /opt/app-root/bin

# OS Packages needs to be installed as root
Expand All @@ -85,7 +88,8 @@ RUN dnf -y upgrade --refresh --nobest --skip-broken --nodocs --noplugins --setop
# upgrade first to avoid fixable vulnerabilities end

# Install useful OS packages
RUN dnf install -y perl mesa-libGL skopeo && dnf clean all && rm -rf /var/cache/yum
COPY --chown=1001:0 ${CODESERVER_SOURCE_CODE}/utils utils/
RUN --mount=type=cache,target=/var/cache/dnf ./utils/install_with_retry.sh dnf-install perl mesa-libGL skopeo

# (ARCH-ppc64le): since wheels are compiled from source, we need shared libs available at runtime
RUN --mount=type=cache,from=whl-cache,source=/root/OpenBLAS,target=/OpenBlas,rw \
Expand Down Expand Up @@ -134,7 +138,7 @@ USER 0
WORKDIR /opt/app-root/bin

# Install useful OS packages
RUN dnf install -y jq git-lfs libsndfile && dnf clean all && rm -rf /var/cache/yum
RUN --mount=type=cache,target=/var/cache/dnf ./utils/install_with_retry.sh dnf-install jq git-lfs libsndfile

# wait for rpm-base stage (rpm builds for ppc64le)
COPY --from=rpm-base /tmp/control /dev/null
Expand Down Expand Up @@ -171,10 +175,10 @@ ENV APP_ROOT=/opt/app-root \
NGINX_PERL_MODULE_PATH=${APP_ROOT}/etc/perl

# Modules does not exist
RUN INSTALL_PKGS="bind-utils nginx nginx-mod-stream nginx-mod-http-perl httpd" && \
dnf install -y --setopt=tsflags=nodocs $INSTALL_PKGS && \
rpm -V $INSTALL_PKGS && \
dnf -y clean all --enablerepo='*'
RUN --mount=type=cache,target=/var/cache/dnf \
DNF_EXTRA_OPTS="--setopt=tsflags=nodocs" ./utils/install_with_retry.sh dnf-install bind-utils nginx nginx-mod-stream nginx-mod-http-perl httpd \
&& rpm -V bind-utils nginx nginx-mod-stream nginx-mod-http-perl httpd \
&& dnf -y clean all --enablerepo='*'

# Configure httpd for CGI processing
COPY --chown=1001:0 ${CODESERVER_SOURCE_CODE}/httpd/httpd.conf /etc/httpd/conf/httpd.conf
Expand Down
4 changes: 2 additions & 2 deletions codeserver/ubi9-python-3.12/get_code_server_rpm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ if [[ "$ARCH" == "amd64" || "$ARCH" == "arm64" ||"$ARCH" == "ppc64le" ]]; then
# install build dependencies
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On my trials the other time I had timeout issues on npm install step, can you wrap that line with the retry script?
https://github.com/daniellutz/odh-notebooks/blob/83c426252f148afac76f61b5e221ef823e21efdd/codeserver/ubi9-python-3.12/get_code_server_rpm.sh#L68C2-L68C13

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the idea of the script (thanks Jiri, again) was to improve that as well, npm install, dnf upgrade and anything that could require the retry loop

let me wrap it as well

Copy link
Author

@daniellutz daniellutz Feb 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added the npm install retry loop as well for codeserver image

on purpose, I did not add the loop to npm run build, let's see if on npm install will be enough

# https://access.redhat.com/support/policy/updates/rhel-app-streams-life-cycle
# https://docs.redhat.com/en/documentation/red_hat_enterprise_linux/9/html/developing_c_and_cpp_applications_in_rhel_9/assembly_additional-toolsets-for-development-rhel-9_developing-applications#cpp-compatibility-in-gcc-toolset-14_gcc-toolset-14
dnf install -y jq patch libtool rsync gettext gcc-toolset-14 krb5-devel libX11-devel
./utils/install_with_retry.sh dnf-install jq patch libtool rsync gettext gcc-toolset-14 krb5-devel libX11-devel

# starting with node-22, c++20 is required
. /opt/rh/gcc-toolset-14/enable
Expand Down Expand Up @@ -65,7 +65,7 @@ if [[ "$ARCH" == "amd64" || "$ARCH" == "arm64" ||"$ARCH" == "ppc64le" ]]; then
source ${NVM_DIR}/nvm.sh
while IFS= read -r src_patch; do echo "patches/$src_patch"; patch -p1 < "patches/$src_patch"; done < patches/series
nvm use ${NODE_VERSION}
npm install
../utils/install_with_retry.sh npm-install
npm run build
VERSION=${CODESERVER_VERSION/v/} npm run build:vscode
npm run release
Expand Down
4 changes: 2 additions & 2 deletions codeserver/ubi9-python-3.12/run-code-server.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/usr/bin/env bash

# Load bash libraries
# Load bash libraries (only process.sh is needed at runtime; install_with_retry.sh is for build-only)
SCRIPT_DIR=$(dirname -- "$0")
source ${SCRIPT_DIR}/utils/*.sh
source "${SCRIPT_DIR}/utils/process.sh"

# Start nginx and httpd
run-nginx.sh &
Expand Down
82 changes: 82 additions & 0 deletions codeserver/ubi9-python-3.12/utils/install_with_retry.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
#!/bin/bash

# Shared install script with retry logic for dnf, texlive (install_pdf_deps), and npm.
# Usage:
# ./install_with_retry.sh dnf-install <package> [package ...]
# ./install_with_retry.sh texlive-install
# ./install_with_retry.sh npm-install

set -Eeuxo pipefail

readonly MAX_RETRIES="${MAX_RETRIES:-3}"
readonly RETRY_DELAY="${RETRY_DELAY:-30}"

# Runs a command with retry logic.
# Optional: set CLEANUP_CMD to a shell command (e.g. "dnf clean metadata") to run between retries.
# Returns 0 on success, exits 1 after MAX_RETRIES failures.
run_with_retry() {
local retry_count=0
while true; do
if "$@"; then
return 0
fi
retry_count=$((retry_count + 1))
if [ "$retry_count" -ge "$MAX_RETRIES" ]; then
echo "ERROR: Command failed after $MAX_RETRIES attempts" >&2
exit 1
fi
echo "Command failed (attempt $retry_count/$MAX_RETRIES), retrying in ${RETRY_DELAY} seconds..."
if [ -n "${CLEANUP_CMD:-}" ]; then
$CLEANUP_CMD || true
fi
sleep "$RETRY_DELAY"
done
}

dnf_install() {
local packages=("$@")
if [ ${#packages[@]} -eq 0 ]; then
echo "Usage: $0 dnf-install <package> [package ...]" >&2
exit 1
fi
CLEANUP_CMD="dnf clean metadata" run_with_retry dnf install -y ${DNF_EXTRA_OPTS:-} "${packages[@]}"
dnf clean all
rm -rf /var/cache/yum
}

texlive_install() {
local script_dir
script_dir="$(cd "$(dirname "$0")" && pwd)"
CLEANUP_CMD= run_with_retry "$script_dir/install_pdf_deps.sh"
}

npm_install() {
CLEANUP_CMD="rm -rf node_modules" run_with_retry npm install
}

main() {
case "${1:-}" in
dnf-install)
shift
dnf_install "$@"
;;
texlive-install)
texlive_install
;;
npm-install)
npm_install
;;
*)
echo "Usage: $0 {dnf-install|texlive-install|npm-install} [args...]" >&2
echo " dnf-install <package> [package ...] Install RPM packages with retry" >&2
echo " texlive-install Run install_pdf_deps.sh with retry" >&2
echo " npm-install Run npm install with retry" >&2
exit 1
;;
esac
}

# Only run main when this script is executed directly (not when sourced by run-code-server.sh)
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
main "$@"
fi
125 changes: 65 additions & 60 deletions jupyter/datascience/ubi9-python-3.12/Dockerfile.cpu
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,16 @@ RUN dnf -y upgrade --refresh --nobest --skip-broken --nodocs --noplugins --setop
# upgrade first to avoid fixable vulnerabilities end

# Install useful OS packages
RUN --mount=type=cache,target=/var/cache/dnf \
echo "Building for architecture: ${TARGETARCH}" && \
if [ "$TARGETARCH" = "s390x" ]; then \
PACKAGES="perl mesa-libGL skopeo gcc gcc-c++ make openssl-devel autoconf automake libtool cmake python3-devel pybind11-devel openblas-devel unixODBC-devel"; \
else \
PACKAGES="perl mesa-libGL skopeo"; \
fi && \
echo "Installing: $PACKAGES" && \
dnf install -y $PACKAGES && \
dnf clean all && rm -rf /var/cache/yum
COPY jupyter/utils utils/
RUN --mount=type=cache,target=/var/cache/dnf /bin/bash <<'EOF'
set -Eeuxo pipefail
echo "Building for architecture: ${TARGETARCH}"
if [ "$TARGETARCH" = "s390x" ]; then
./utils/install_with_retry.sh dnf-install perl mesa-libGL skopeo gcc gcc-c++ make openssl-devel autoconf automake libtool cmake python3-devel pybind11-devel openblas-devel unixODBC-devel
else
./utils/install_with_retry.sh dnf-install perl mesa-libGL skopeo
fi
EOF

RUN if [ "$TARGETARCH" = "s390x" ]; then \
# Install Rust and set up environment
Expand Down Expand Up @@ -114,51 +114,58 @@ WORKDIR /tmp/build-wheels

# Build pyarrow on ppc64le and s390x
RUN --mount=type=cache,target=/root/.cache/pip \
--mount=type=cache,target=/root/.cache/dnf \
if [ "$TARGETARCH" = "ppc64le" ] || [ "$TARGETARCH" = "s390x" ]; then \
# Install build dependencies (shared for pyarrow and onnx)
dnf install -y cmake make gcc-c++ pybind11-devel wget && \
dnf clean all && \
# Build and collect pyarrow wheel
git clone --depth 1 --branch "apache-arrow-17.0.0" https://github.com/apache/arrow.git && \
cd arrow/cpp && \
mkdir release && cd release && \
cmake -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=/usr/local \
-DARROW_PYTHON=ON \
-DARROW_PARQUET=ON \
-DARROW_ORC=ON \
-DARROW_FILESYSTEM=ON \
-DARROW_JSON=ON \
-DARROW_CSV=ON \
-DARROW_DATASET=ON \
-DARROW_DEPENDENCY_SOURCE=BUNDLED \
-DARROW_WITH_LZ4=OFF \
-DARROW_WITH_ZSTD=OFF \
-DARROW_WITH_SNAPPY=OFF \
-DARROW_BUILD_TESTS=OFF \
-DARROW_BUILD_BENCHMARKS=OFF \
.. && \
make -j$(nproc) VERBOSE=1 && \
make install -j$(nproc) && \
cd ../../python && \
pip install --no-cache-dir -r requirements-build.txt && \
PYARROW_WITH_PARQUET=1 \
PYARROW_WITH_DATASET=1 \
PYARROW_WITH_FILESYSTEM=1 \
PYARROW_WITH_JSON=1 \
PYARROW_WITH_CSV=1 \
PYARROW_PARALLEL=$(nproc) \
python setup.py build_ext --build-type=release --bundle-arrow-cpp bdist_wheel && \
mkdir -p /tmp/wheels && \
cp dist/pyarrow-*.whl /tmp/wheels/ && \
chmod -R 777 /tmp/wheels && \
# Ensure wheels directory exists and has content
ls -la /tmp/wheels/; \
else \
# Create empty wheels directory for non-s390x
mkdir -p /tmp/wheels; \
fi
--mount=type=cache,target=/root/.cache/dnf /bin/bash <<'EOF'
set -Eeuxo pipefail

if [ "$TARGETARCH" = "ppc64le" ] || [ "$TARGETARCH" = "s390x" ]; then
/opt/app-root/bin/utils/install_with_retry.sh dnf-install cmake make gcc-c++ pybind11-devel wget

# Build and collect pyarrow wheel
git clone --depth 1 --branch "apache-arrow-17.0.0" https://github.com/apache/arrow.git
cd arrow/cpp && mkdir release && cd release

cmake -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=/usr/local \
-DARROW_PYTHON=ON \
-DARROW_PARQUET=ON \
-DARROW_ORC=ON \
-DARROW_FILESYSTEM=ON \
-DARROW_JSON=ON \
-DARROW_CSV=ON \
-DARROW_DATASET=ON \
-DARROW_DEPENDENCY_SOURCE=BUNDLED \
-DARROW_WITH_LZ4=OFF \
-DARROW_WITH_ZSTD=OFF \
-DARROW_WITH_SNAPPY=OFF \
-DARROW_BUILD_TESTS=OFF \
-DARROW_BUILD_BENCHMARKS=OFF \
..

make -j$(nproc) VERBOSE=1
make install -j$(nproc)

cd ../../python

pip install --no-cache-dir -r requirements-build.txt

PYARROW_WITH_PARQUET=1 \
PYARROW_WITH_DATASET=1 \
PYARROW_WITH_FILESYSTEM=1 \
PYARROW_WITH_JSON=1 \
PYARROW_WITH_CSV=1 \
PYARROW_PARALLEL=$(nproc) \
python setup.py build_ext --build-type=release --bundle-arrow-cpp bdist_wheel

mkdir -p /tmp/wheels
cp dist/pyarrow-*.whl /tmp/wheels/
chmod -R 777 /tmp/wheels
# Ensure wheels directory exists and has content
ls -la /tmp/wheels/;
else
# Create empty wheels directory for non-s390x
mkdir -p /tmp/wheels;
fi
EOF

#######################################################
# common-builder (for Power-only)
Expand All @@ -169,8 +176,7 @@ USER root
RUN <<'EOF'
set -Eeuxo pipefail
if [ "${TARGETARCH}" = "ppc64le" ]; then
dnf install -y gcc-toolset-13 cmake ninja-build git wget unzip
dnf clean all
/opt/app-root/bin/utils/install_with_retry.sh dnf-install gcc-toolset-13 cmake ninja-build git wget unzip
else
echo "Skipping common-builder package install on non-Power"
fi
Expand Down Expand Up @@ -235,7 +241,7 @@ COPY ${MINIMAL_SOURCE_CODE}/start-notebook.sh ./
USER 0

# Dependencies for PDF export begin
RUN ./utils/install_pdf_deps.sh
RUN ./utils/install_with_retry.sh texlive-install
ENV PATH="/usr/local/texlive/bin/linux:/usr/local/pandoc/bin:$PATH"
# Dependencies for PDF export end

Expand Down Expand Up @@ -272,8 +278,7 @@ WORKDIR /opt/app-root/bin
USER root

# Install useful OS packages
RUN dnf install -y jq unixODBC unixODBC-devel postgresql git-lfs libsndfile libxcrypt-compat && \
dnf clean all && rm -rf /var/cache/yum
RUN ./utils/install_with_retry.sh dnf-install jq unixODBC unixODBC-devel postgresql git-lfs libsndfile libxcrypt-compat

# Copy dynamically-linked mongocli built in earlier build stage
COPY --from=mongocli-builder /tmp/mongocli /opt/app-root/bin/
Expand Down
Loading
Loading