From 0074e35218dd93cbcc5f04f05567ba1649ab8cbe Mon Sep 17 00:00:00 2001 From: puneetsharma21 Date: Wed, 30 Jul 2025 00:52:04 -0400 Subject: [PATCH 1/6] Fix TeX Live and Pandoc for multi-arch support Signed-off-by: puneetsharma21 --- .../minimal/ubi9-python-3.11/Dockerfile.cpu | 25 +++++- .../minimal/ubi9-python-3.12/Dockerfile.cpu | 24 ++++- jupyter/utils/install_pandoc.sh | 53 +++++++++++ jupyter/utils/install_texlive.sh | 89 +++++++++++++++++++ 4 files changed, 187 insertions(+), 4 deletions(-) create mode 100644 jupyter/utils/install_pandoc.sh create mode 100644 jupyter/utils/install_texlive.sh diff --git a/jupyter/minimal/ubi9-python-3.11/Dockerfile.cpu b/jupyter/minimal/ubi9-python-3.11/Dockerfile.cpu index c5eab5d0b3..50477dd0b7 100644 --- a/jupyter/minimal/ubi9-python-3.11/Dockerfile.cpu +++ b/jupyter/minimal/ubi9-python-3.11/Dockerfile.cpu @@ -1,3 +1,21 @@ +############################ +# Stage 1: PDF Tool Build # +############################ +FROM registry.access.redhat.com/ubi9/python-311:latest AS pdf-builder + +WORKDIR /opt/app-root/bin + +# OS Packages needs to be installed as root +USER 0 + +# Copy scripts +COPY jupyter/utils/install_texlive.sh ./install_texlive.sh +COPY jupyter/utils/install_pandoc.sh ./install_pandoc.sh +RUN chmod +x install_texlive.sh install_pandoc.sh + +RUN ./install_texlive.sh +RUN ./install_pandoc.sh + #################### # base # #################### @@ -47,8 +65,10 @@ COPY ${JUPYTER_REUSABLE_UTILS} utils/ USER 0 -# Dependencies for PDF export -RUN ./utils/install_pdf_deps.sh +# Copy built TeXLive and Pandoc binaries only (no build deps) +COPY --from=pdf-builder /usr/local/texlive /usr/local/texlive +COPY --from=pdf-builder /usr/local/pandoc /usr/local/pandoc + ENV PATH="/usr/local/texlive/bin/linux:/usr/local/pandoc/bin:$PATH" USER 1001 @@ -74,3 +94,4 @@ RUN echo "Installing softwares and packages" && \ WORKDIR /opt/app-root/src ENTRYPOINT ["start-notebook.sh"] + diff --git a/jupyter/minimal/ubi9-python-3.12/Dockerfile.cpu b/jupyter/minimal/ubi9-python-3.12/Dockerfile.cpu index bfaa481ee9..dd0cabbf5c 100644 --- a/jupyter/minimal/ubi9-python-3.12/Dockerfile.cpu +++ b/jupyter/minimal/ubi9-python-3.12/Dockerfile.cpu @@ -1,3 +1,21 @@ +############################ +# Stage 1: PDF Tool Build # +############################ +FROM registry.access.redhat.com/ubi9/python-312:latest AS pdf-builder + +WORKDIR /opt/app-root/bin + +# OS Packages needs to be installed as root +USER 0 + +# Copy scripts +COPY jupyter/utils/install_texlive.sh ./install_texlive.sh +COPY jupyter/utils/install_pandoc.sh ./install_pandoc.sh +RUN chmod +x install_texlive.sh install_pandoc.sh + +RUN ./install_texlive.sh +RUN ./install_pandoc.sh + #################### # base # #################### @@ -47,8 +65,10 @@ COPY ${JUPYTER_REUSABLE_UTILS} utils/ USER 0 -# Dependencies for PDF export -RUN ./utils/install_pdf_deps.sh +# Copy built TeXLive and Pandoc binaries only (no build deps) +COPY --from=pdf-builder /usr/local/texlive /usr/local/texlive +COPY --from=pdf-builder /usr/local/pandoc /usr/local/pandoc + ENV PATH="/usr/local/texlive/bin/linux:/usr/local/pandoc/bin:$PATH" USER 1001 diff --git a/jupyter/utils/install_pandoc.sh b/jupyter/utils/install_pandoc.sh new file mode 100644 index 0000000000..ae94ebc81a --- /dev/null +++ b/jupyter/utils/install_pandoc.sh @@ -0,0 +1,53 @@ +#!/bin/bash +set -euxo pipefail + +# Mapping of `uname -m` values to equivalent GOARCH values +declare -A UNAME_TO_GOARCH +UNAME_TO_GOARCH["x86_64"]="amd64" +UNAME_TO_GOARCH["aarch64"]="arm64" +UNAME_TO_GOARCH["ppc64le"]="ppc64le" +UNAME_TO_GOARCH["s390x"]="s390x" + +ARCH="${UNAME_TO_GOARCH[$(uname -m)]}" + +if [[ "$ARCH" == "ppc64le" ]]; then + # Install Pandoc from source + dnf install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm + dnf install -y cabal-install ghc gmp-devel + + # Set version + PANDOC_VERSION=3.7.0.2 + + cd /tmp + git clone --recurse-submodules https://github.com/jgm/pandoc.git + cd pandoc + git checkout ${PANDOC_VERSION} + git submodule update --init --recursive + + cabal update + cd pandoc-cli + cabal build -j"$(nproc)" + mkdir -p /usr/local/pandoc/bin + cabal install \ + --installdir=/usr/local/pandoc/bin \ + --overwrite-policy=always \ + --install-method=copy + + # Clean up Haskell build system + rm -rf ~/.cabal ~/.ghc /tmp/pandoc + dnf remove -y cabal-install ghc gmp-devel + dnf clean all && rm -rf /var/cache/dnf + + /usr/local/pandoc/bin/pandoc --version + +elif [[ "$ARCH" == "amd64" ]]; then + # pandoc installation + curl -fL "https://github.com/jgm/pandoc/releases/download/3.7.0.2/pandoc-3.7.0.2-linux-${ARCH}.tar.gz" -o /tmp/pandoc.tar.gz + mkdir -p /usr/local/pandoc + tar xvzf /tmp/pandoc.tar.gz --strip-components 1 -C /usr/local/pandoc/ + rm -f /tmp/pandoc.tar.gz + +else + echo "Unsupported architecture: $ARCH" >&2 + exit 1 +fi diff --git a/jupyter/utils/install_texlive.sh b/jupyter/utils/install_texlive.sh new file mode 100644 index 0000000000..3f0c190530 --- /dev/null +++ b/jupyter/utils/install_texlive.sh @@ -0,0 +1,89 @@ +#!/bin/bash +set -euxo pipefail + +# Mapping of `uname -m` values to equivalent GOARCH values +declare -A UNAME_TO_GOARCH +UNAME_TO_GOARCH["x86_64"]="amd64" +UNAME_TO_GOARCH["aarch64"]="arm64" +UNAME_TO_GOARCH["ppc64le"]="ppc64le" +UNAME_TO_GOARCH["s390x"]="s390x" + +ARCH="${UNAME_TO_GOARCH[$(uname -m)]}" + +if [[ "$ARCH" == "ppc64le" ]]; then + echo "Installing TeX Live from source for $ARCH..." + + # Install build dependencies + dnf install -y gcc-toolset-13 perl make libX11-devel libXt-devel \ + zlib-devel freetype-devel libpng-devel ncurses-devel \ + gd-devel libtool wget tar xz bison flex libXaw-devel + + # Step 1: Download and extract the TeX Live source + wget https://ftp.math.utah.edu/pub/tex/historic/systems/texlive/2025/texlive-20250308-source.tar.xz + tar -xf texlive-20250308-source.tar.xz + cd texlive-20250308-source + + # Enable newer GCC toolchain + source /opt/rh/gcc-toolset-13/enable + + # Create build directory and build + mkdir ../texlive-build + cd ../texlive-build + ../texlive-20250308-source/configure --prefix=/usr/local/texlive + make -j"$(nproc)" + make install + + # Symlink for pdflatex + ln -sf pdftex /usr/local/texlive/bin/powerpc64le-unknown-linux-gnu/pdflatex + + # Cleanup sources to reduce image size + rm -rf /texlive-20250308-source /texlive-build + + # Step 2: Run TeX Live installer for runtime tree setup + cd / + wget http://mirror.ctan.org/systems/texlive/tlnet/install-tl-unx.tar.gz + tar -xzf install-tl-unx.tar.gz + cd install-tl-2*/ + + # Create a custom install profile + TEXLIVE_INSTALL_PREFIX="/usr/local/texlive" + cat < texlive.profile +selected_scheme scheme-small +TEXDIR $TEXLIVE_INSTALL_PREFIX +TEXMFCONFIG ~/.texlive2025/texmf-config +TEXMFVAR ~/.texlive2025/texmf-var +option_doc 0 +option_src 0 +EOF + + ./install-tl --profile=texlive.profile --custom-bin=$TEXLIVE_INSTALL_PREFIX/bin/powerpc64le-unknown-linux-gnu + +# TeX Live binary directory +TEX_BIN_DIR="/usr/local/texlive/bin/powerpc64le-unknown-linux-gnu" + +# Create standard symlink 'linux' → arch-specific folder +ln -sf "$TEX_BIN_DIR" /usr/local/texlive/bin/linux + + + # Set up environment + export PATH="$TEXLIVE_INSTALL_PREFIX/bin/linux:$PATH" + pdflatex --version + tlmgr --version + +elif [[ "$ARCH" == "amd64" ]]; then + # tex live installation + echo "Installing TexLive to allow PDf export from Notebooks" + curl -fL https://mirror.ctan.org/systems/texlive/tlnet/install-tl-unx.tar.gz -o install-tl-unx.tar.gz + zcat < install-tl-unx.tar.gz | tar xf - + cd install-tl-2* + perl ./install-tl --no-interaction --scheme=scheme-small --texdir=/usr/local/texlive + mv /usr/local/texlive/bin/"$(uname -m)-linux" /usr/local/texlive/bin/linux + cd /usr/local/texlive/bin/linux + ./tlmgr install tcolorbox pdfcol adjustbox titling enumitem soul ucs collection-fontsrecommended + +else + echo "Unsupported architecture: $ARCH" >&2 + exit 1 + +fi + From 9522ef1ff50dbcc0d1c04b7dd9a8067b2f8d9a92 Mon Sep 17 00:00:00 2001 From: puneetsharma21 Date: Wed, 30 Jul 2025 08:48:53 -0400 Subject: [PATCH 2/6] Add CentOS Stream and EPEL repos to install missing TeX Live deps on ppc64le Signed-off-by: puneetsharma21 --- jupyter/utils/install_texlive.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/jupyter/utils/install_texlive.sh b/jupyter/utils/install_texlive.sh index 3f0c190530..5372c83578 100644 --- a/jupyter/utils/install_texlive.sh +++ b/jupyter/utils/install_texlive.sh @@ -14,6 +14,12 @@ if [[ "$ARCH" == "ppc64le" ]]; then echo "Installing TeX Live from source for $ARCH..." # Install build dependencies + dnf install -y https://mirror.stream.centos.org/9-stream/BaseOS/ppc64le/os/Packages/centos-gpg-keys-9.0-24.el9.noarch.rpm \ + https://mirror.stream.centos.org/9-stream/BaseOS/`arch`/os/Packages/centos-stream-repos-9.0-24.el9.noarch.rpm \ + https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm + dnf config-manager --add-repo https://mirror.stream.centos.org/9-stream/BaseOS/ppc64le/os + dnf config-manager --add-repo https://mirror.stream.centos.org/9-stream/AppStream/ppc64le/os + dnf config-manager --set-enabled crb dnf install -y gcc-toolset-13 perl make libX11-devel libXt-devel \ zlib-devel freetype-devel libpng-devel ncurses-devel \ gd-devel libtool wget tar xz bison flex libXaw-devel From 7a6abc729a0a6de7577467415e70f60e97698c34 Mon Sep 17 00:00:00 2001 From: puneetsharma21 Date: Thu, 31 Jul 2025 06:13:34 -0400 Subject: [PATCH 3/6] Disable temporary CentOS Stream repos after installing TeX Live dependencies on ppc64le Signed-off-by: puneetsharma21 --- jupyter/utils/install_texlive.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/jupyter/utils/install_texlive.sh b/jupyter/utils/install_texlive.sh index 5372c83578..6385f1f84a 100644 --- a/jupyter/utils/install_texlive.sh +++ b/jupyter/utils/install_texlive.sh @@ -24,6 +24,12 @@ if [[ "$ARCH" == "ppc64le" ]]; then zlib-devel freetype-devel libpng-devel ncurses-devel \ gd-devel libtool wget tar xz bison flex libXaw-devel + # Disable temporary CentOS Stream repos after use + dnf config-manager --disable \ + mirror.stream.centos.org_9-stream_BaseOS_ppc64le_os \ + mirror.stream.centos.org_9-stream_AppStream_ppc64le_os \ + crb + # Step 1: Download and extract the TeX Live source wget https://ftp.math.utah.edu/pub/tex/historic/systems/texlive/2025/texlive-20250308-source.tar.xz tar -xf texlive-20250308-source.tar.xz From 240aa791898ea0e9ce55bd45f71f68e9b262ba2c Mon Sep 17 00:00:00 2001 From: puneetsharma21 Date: Fri, 1 Aug 2025 07:41:00 -0400 Subject: [PATCH 4/6] update user config to avoid 403 error from Hackage during cabal update Signed-off-by: puneetsharma21 --- jupyter/utils/install_pandoc.sh | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/jupyter/utils/install_pandoc.sh b/jupyter/utils/install_pandoc.sh index ae94ebc81a..a0debc0119 100644 --- a/jupyter/utils/install_pandoc.sh +++ b/jupyter/utils/install_pandoc.sh @@ -24,6 +24,15 @@ if [[ "$ARCH" == "ppc64le" ]]; then git checkout ${PANDOC_VERSION} git submodule update --init --recursive + export HOME=/root + # Initialize cabal user config (don't fail if already done) + cabal user-config init || true + + # Modify config + echo "repository hackage.haskell.org + url: https://hackage.haskell.org/ + secure: False" >> $HOME/.cabal/config + cabal update cd pandoc-cli cabal build -j"$(nproc)" From d031ee570cd8c303e4e250709bb5407496e130bf Mon Sep 17 00:00:00 2001 From: puneetsharma21 Date: Wed, 6 Aug 2025 09:14:37 -0400 Subject: [PATCH 5/6] Replace CentOS repo-based installs with direct RPM installation for UBI compatibility Signed-off-by: puneetsharma21 --- jupyter/utils/install_texlive.sh | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/jupyter/utils/install_texlive.sh b/jupyter/utils/install_texlive.sh index 6385f1f84a..b8926f1fd2 100644 --- a/jupyter/utils/install_texlive.sh +++ b/jupyter/utils/install_texlive.sh @@ -14,21 +14,15 @@ if [[ "$ARCH" == "ppc64le" ]]; then echo "Installing TeX Live from source for $ARCH..." # Install build dependencies - dnf install -y https://mirror.stream.centos.org/9-stream/BaseOS/ppc64le/os/Packages/centos-gpg-keys-9.0-24.el9.noarch.rpm \ - https://mirror.stream.centos.org/9-stream/BaseOS/`arch`/os/Packages/centos-stream-repos-9.0-24.el9.noarch.rpm \ - https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm - dnf config-manager --add-repo https://mirror.stream.centos.org/9-stream/BaseOS/ppc64le/os - dnf config-manager --add-repo https://mirror.stream.centos.org/9-stream/AppStream/ppc64le/os - dnf config-manager --set-enabled crb - dnf install -y gcc-toolset-13 perl make libX11-devel libXt-devel \ + dnf install -y gcc-toolset-13 perl make libX11-devel \ zlib-devel freetype-devel libpng-devel ncurses-devel \ - gd-devel libtool wget tar xz bison flex libXaw-devel + gd-devel libtool wget tar xz - # Disable temporary CentOS Stream repos after use - dnf config-manager --disable \ - mirror.stream.centos.org_9-stream_BaseOS_ppc64le_os \ - mirror.stream.centos.org_9-stream_AppStream_ppc64le_os \ - crb + rpm -ivh --nodeps https://mirror.stream.centos.org/9-stream/AppStream/ppc64le/os/Packages/libXt-devel-1.2.0-6.el9.ppc64le.rpm + rpm -ivh --nodeps https://mirror.stream.centos.org/9-stream/AppStream/ppc64le/os/Packages/libXaw-1.0.13-19.el9.ppc64le.rpm + rpm -ivh --nodeps https://mirror.stream.centos.org/9-stream/AppStream/ppc64le/os/Packages/libXaw-devel-1.0.13-19.el9.ppc64le.rpm + rpm -ivh --nodeps https://mirror.stream.centos.org/9-stream/AppStream/ppc64le/os/Packages/flex-2.6.4-9.el9.ppc64le.rpm + rpm -ivh --nodeps https://mirror.stream.centos.org/9-stream/AppStream/ppc64le/os/Packages/bison-3.7.4-5.el9.ppc64le.rpm # Step 1: Download and extract the TeX Live source wget https://ftp.math.utah.edu/pub/tex/historic/systems/texlive/2025/texlive-20250308-source.tar.xz @@ -53,7 +47,7 @@ if [[ "$ARCH" == "ppc64le" ]]; then # Step 2: Run TeX Live installer for runtime tree setup cd / - wget http://mirror.ctan.org/systems/texlive/tlnet/install-tl-unx.tar.gz + wget https://mirror.ctan.org/systems/texlive/tlnet/install-tl-unx.tar.gz tar -xzf install-tl-unx.tar.gz cd install-tl-2*/ From 3c790adfec406eaaca3a3f3138f87b33a2a63604 Mon Sep 17 00:00:00 2001 From: puneetsharma21 Date: Thu, 7 Aug 2025 01:34:51 -0400 Subject: [PATCH 6/6] Replace CentOS repo-based installs with direct RPM installation Signed-off-by: puneetsharma21 --- jupyter/utils/install_texlive.sh | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/jupyter/utils/install_texlive.sh b/jupyter/utils/install_texlive.sh index b8926f1fd2..f74e9e5ec9 100644 --- a/jupyter/utils/install_texlive.sh +++ b/jupyter/utils/install_texlive.sh @@ -18,11 +18,16 @@ if [[ "$ARCH" == "ppc64le" ]]; then zlib-devel freetype-devel libpng-devel ncurses-devel \ gd-devel libtool wget tar xz - rpm -ivh --nodeps https://mirror.stream.centos.org/9-stream/AppStream/ppc64le/os/Packages/libXt-devel-1.2.0-6.el9.ppc64le.rpm - rpm -ivh --nodeps https://mirror.stream.centos.org/9-stream/AppStream/ppc64le/os/Packages/libXaw-1.0.13-19.el9.ppc64le.rpm - rpm -ivh --nodeps https://mirror.stream.centos.org/9-stream/AppStream/ppc64le/os/Packages/libXaw-devel-1.0.13-19.el9.ppc64le.rpm - rpm -ivh --nodeps https://mirror.stream.centos.org/9-stream/AppStream/ppc64le/os/Packages/flex-2.6.4-9.el9.ppc64le.rpm - rpm -ivh --nodeps https://mirror.stream.centos.org/9-stream/AppStream/ppc64le/os/Packages/bison-3.7.4-5.el9.ppc64le.rpm + rpm -q libXmu-devel || rpm -ivh --nodeps https://mirror.stream.centos.org/9-stream/AppStream/ppc64le/os/Packages/libXmu-devel-1.1.3-8.el9.ppc64le.rpm + rpm -q libXext-devel|| rpm -ivh --nodeps https://mirror.stream.centos.org/9-stream/AppStream/ppc64le/os/Packages/libXext-devel-1.3.4-8.el9.ppc64le.rpm + rpm -q libICE-devel || rpm -ivh --nodeps https://mirror.stream.centos.org/9-stream/AppStream/ppc64le/os/Packages/libICE-devel-1.0.10-8.el9.ppc64le.rpm + rpm -q libSM-devel || rpm -ivh --nodeps https://mirror.stream.centos.org/9-stream/AppStream/ppc64le/os/Packages/libSM-devel-1.2.3-10.el9.ppc64le.rpm + rpm -q libXmu || rpm -ivh --nodeps https://mirror.stream.centos.org/9-stream/AppStream/ppc64le/os/Packages/libXmu-1.1.3-8.el9.ppc64le.rpm + rpm -q libXaw-devel || rpm -ivh --nodeps https://mirror.stream.centos.org/9-stream/AppStream/ppc64le/os/Packages/libXaw-devel-1.0.13-19.el9.ppc64le.rpm + rpm -q libXaw || rpm -ivh --nodeps https://mirror.stream.centos.org/9-stream/AppStream/ppc64le/os/Packages/libXaw-1.0.13-19.el9.ppc64le.rpm + rpm -q libXt-devel || rpm -ivh --nodeps https://mirror.stream.centos.org/9-stream/AppStream/ppc64le/os/Packages/libXt-devel-1.2.0-6.el9.ppc64le.rpm + rpm -q flex || rpm -ivh --nodeps https://mirror.stream.centos.org/9-stream/AppStream/ppc64le/os/Packages/flex-2.6.4-9.el9.ppc64le.rpm + rpm -q bison || rpm -ivh --nodeps https://mirror.stream.centos.org/9-stream/AppStream/ppc64le/os/Packages/bison-3.7.4-5.el9.ppc64le.rpm # Step 1: Download and extract the TeX Live source wget https://ftp.math.utah.edu/pub/tex/historic/systems/texlive/2025/texlive-20250308-source.tar.xz @@ -33,7 +38,7 @@ if [[ "$ARCH" == "ppc64le" ]]; then source /opt/rh/gcc-toolset-13/enable # Create build directory and build - mkdir ../texlive-build + mkdir -p ../texlive-build cd ../texlive-build ../texlive-20250308-source/configure --prefix=/usr/local/texlive make -j"$(nproc)"