General workflow for container images is:
- Image is built on a local computer using Podman/Docker
- Image is pushed to GitHub container registry (ghcr.io)
- Image is pulled to supercomputer using Singularity/Apptainer from ghcr.io as described in README
For each container variant, there are two files:
Dockerfile
: This is the recipe for building a container imageMakefile
: This is a helper file for simplifying building the image (so that one can saymake build
instead ofdocker buildx build --platform ... --build-arg ...
)
Install docker or podman:
sudo apt install podman-docker
Add the following environment variable to ~/.bashrc
or redefine it always before running build commands:
export BUILDAH_FORMAT=docker
Typical workflow is:
-
Important: Update
IMAGE_VERSION
variable inMakefile
. If this is not done, an existing image with the same version gets overwritten, which is problematic for reproducibility. -
Update
Dockerfile
and/orMakefile
as needed, see especially version numbers inMakefile
. -
Build a new image:
make build
-
Login to GitHub container registry. Use GitHub username and Personal Access Token with scope 'write:packages' as username and password, respectively. See these instructions for creating a token.
docker login ghcr.io
-
Push the image to ghcr.io:
make push
You can test the image locally before pushing it to ghcr.io.
Example for running python interpreter with the image:
docker run -it --rm --entrypoint python3 IMAGE_NAME:IMAGE_VERSION
You can convert a local (not necessarily pushed) image to singularity:
make singularity
The resulting sif file can be used as if it was pulled from ghcr.io as described in README.