Skip to content

Add TeX Live and Pandoc installation for ppc64le #1179

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 7 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
27 changes: 24 additions & 3 deletions jupyter/minimal/ubi9-python-3.11/Dockerfile.cpu
Original file line number Diff line number Diff line change
@@ -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 #
####################
Expand Down Expand Up @@ -47,9 +65,11 @@ COPY ${JUPYTER_REUSABLE_UTILS} utils/

USER 0

# Dependencies for PDF export
RUN ./utils/install_pdf_deps.sh
ENV PATH="/usr/local/texlive/bin/linux:/usr/local/pandoc/bin:$PATH"
# 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/powerpc64le-unknown-linux-gnu:/usr/local/texlive/bin/linux:/usr/local/pandoc/bin:$PATH"

USER 1001

Expand All @@ -74,3 +94,4 @@ RUN echo "Installing softwares and packages" && \
WORKDIR /opt/app-root/src

ENTRYPOINT ["start-notebook.sh"]

39 changes: 39 additions & 0 deletions jupyter/utils/install_pandoc.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/bin/bash
set -euxo pipefail

ARCH=$(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

Comment on lines +15 to +17
Copy link
Contributor

@coderabbitai coderabbitai bot Jul 14, 2025

Choose a reason for hiding this comment

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

⚠️ Potential issue

git missing – build will exit on first git clone
git is not part of the UBI9 minimal image and is not added to the build-deps list, so the very next command (git clone) fails on ppc64le.

-  dnf install -y cabal-install ghc gmp-devel
+  dnf install -y git cabal-install ghc gmp-devel-  dnf remove -y cabal-install ghc gmp-devel
+  dnf remove -y git cabal-install ghc gmp-devel
🤖 Prompt for AI Agents
In jupyter/utils/install_pandoc.sh around lines 15 to 17, the script installs
dependencies but misses installing git, which causes the subsequent git clone
command to fail on ppc64le. Add git to the list of packages installed by dnf to
ensure the git clone command succeeds during the build.

Copy link
Member

Choose a reason for hiding this comment

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

we don't run from ubi9 minimal, we use s2i python image here, so git is present

it may be a good idea to install it explicitly, just in case we ever want to leave s2i

but that's not work for this PR

Copy link
Contributor

Choose a reason for hiding this comment

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

@jiridanek Thank you for the clarification! You're absolutely right - I missed that this is running on the s2i Python image where git is already available, not the minimal UBI9 base.

I appreciate the context about the base image and the future-proofing consideration. The suggestion to explicitly install git makes sense for when/if you transition away from s2i, but as you noted, that's outside the scope of this PR.


✏️ Learnings added
Learnt from: jiridanek
PR: opendatahub-io/notebooks#1179
File: jupyter/utils/install_pandoc.sh:15-17
Timestamp: 2025-07-25T12:03:39.134Z
Learning: The Jupyter notebook images in this repository use s2i Python base images, not minimal UBI9 images, so git is already available and doesn't need to be explicitly installed in build scripts.

Learnt from: jiridanek
PR: opendatahub-io/notebooks#1179
File: jupyter/utils/install_pandoc.sh:15-17
Timestamp: 2025-07-25T12:03:39.134Z
Learning: When reviewing installation scripts in jupyter/utils/, consider that future-proofing suggestions (like explicitly installing git) may be valuable but should be scoped appropriately to the current PR's objectives.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.

# 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)
cabal install --installdir=/usr/local --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
fi

if [[ "$ARCH" == "x86_64" ]]; then
# pandoc installation
curl -L https://github.com/jgm/pandoc/releases/download/3.7.0.2/pandoc-3.7.0.2-linux-amd64.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
fi

/usr/local/pandoc --version
51 changes: 51 additions & 0 deletions jupyter/utils/install_texlive.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/bin/bash
set -euxo pipefail

ARCH=$(uname -m)

if [[ "$ARCH" == "ppc64le" ]]; then
echo "Installing TeX Live from source for $ARCH"

# Download and extract 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

# 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

source /opt/rh/gcc-toolset-13/enable

# Create build directory
mkdir ../texlive-build
cd ../texlive-build

# Configure, build, install
../texlive-20250308-source/configure --prefix=/usr/local/texlive
make -j$(nproc)
make install

# Symlink for pdflatex
cd /usr/local/texlive/bin/powerpc64le-unknown-linux-gnu
ln -s pdftex pdflatex

# Cleanup TeX source to reduce image size
rm -rf /texlive-20250308-source /texlive-build

export PATH="/usr/local/texlive/bin/powerpc64le-unknown-linux-gnu:$PATH"
pdflatex --version
fi

if [[ "$ARCH" == "x86_64" ]]; then
# tex live installation
echo "Installing TexLive to allow PDf export from Notebooks"
curl -L 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
cd /usr/local/texlive/bin/x86_64-linux
./tlmgr install tcolorbox pdfcol adjustbox titling enumitem soul ucs collection-fontsrecommended
fi

Loading