Bonus Episode: Building and deploying an Apptainer container to GitHub Packages#
Overview
Teaching: 40 min | Exercises: 0 min
Questions
How to build an Apptainer container for Python packages?
How to share Apptainer images?
Objectives
To be able to build an Apptainer container and share it via GitHub Packages
Prerequisites
The previous episode ended the Introduction to Apptainer/Singularity. This bonus episode is an optional extension mixing knowledge from different courses. For this lesson, you will also need:
Knowledge of Git SW Carpentry Git-Novice Lesson (for simplified authentication with the
ghCLI, see this version of the git training)Knowledge of GitHub CI/CD HSF Github CI/CD Lesson
Apptainer Container for Python packages#
Python packages can be installed using an Apptainer image. The following example illustrates how to write a definition file for building an image containing Python packages.
Bootstrap: docker
From: ubuntu:24.04
%post
apt-get update -y
apt-get install -y python3 python3-pip
pip3 install --break-system-packages numpy awkward uproot particle hepunits \
matplotlib hist mplhep vector fastjet iminuit
As we see, several Python packages from the Scikit-HEP ecosystem are installed.
The --break-system-packages option is needed to install packages with pip outside a virtual environment
on modern Ubuntu versions, as seen in the instances episode.