kaufman-lab / build_containers

build and deploy kaufman lab singularity containers
GNU Lesser General Public License v2.1
1 stars 2 forks source link

build_containers

This repo builds and stores singularity images to be used in lab workflows.

Available Images

The set of image types that are available are displayed on the right under "packages".

These are the current image types:

Using Images

If you'd like to test out an image interactively, try

singularity shell oras://ghcr.io/kaufman-lab/geospatial_plus:4.1.0

Note that singularity will cache remote images, so using the oras URI (as above) may be more convenient than finding a storage location for the .sif file. However, there may be a tradeoff since using the URI pulls a hash so there is probably a slight delay to starting the image. If you want to instead download the image, you can use singularity pull.

Please disregard the instructions under github packages on how to pull these images using docker commands. These are not docker images and those commands will not work. Those instructions are auto-generated by github and I don't know how to turn them off.

Image Requests

Submit an issue if you'd like additional packages or software built into an image.

Depending on the complexity, we may start a new image type (package) or add to an existing image.

Image Stability

Within a version-tag (e.g. geospatial_plus:4.1.0), R packages built into the image are stable, even when the image (including the underlying rocker image) is rebuilt because of how versioned rocker images install packages. Installing new R packages into the user library, while not recommended (it's better to request a package be added to the image), is also stable (the same version will always be installed) because install.packages by default downloads from a specific date's snapshot of the rstudio package manager. Python packages built into the image are stable because they are all manually specified as pip install commands with a version specified. However, unlike for R packages, installing python packages into the user directory is not reproducible because pip install will just download the newest version. If anyone is aware of a tool that makes pip install point to a specific day's snapshot of pypi (similar to how rstudio package manager/MRAN works) please let me know.

Using images interactively

While these images can be used non-interactively to run R and Python scripts (e.g. via singularity exec oras://ghcr.io/kaufman-lab/geospatial_plus:4.1.0 Rscript scriptname.R) without any additional options, if you want to use the image interactively for development (e.g. via singularity shell or singularity instance) you should --bind a directory on the host machine to /pseudohome. This will allow installation of R and Python packages to an instance/shell-specific directory thus fully isolating the instance even during development. Without first binding pseudohome, user installation of packages will fail because pseudohome does not exist inside the image. This is arguably a good thing because it prevents accidental installation of packages or accidental loading of packages installed in the user library when images are being used for production.

Definition files

This repository uses a pre-commit hook to auto-generate definition files. If you want to edit a definition, do not edit the definition files directly. Instead, edit the contents of build_scripts which get automatically pasted together into definition files during the pre-commit hook. The pre-commit hooked is tracked as part of the repository. In order to use it, you'll need to tell git to use a non-default hook directory and then set the pre-commit hook as executable.

git config --local core.hooksPath githooks/
chmod -R u+x ./githooks/pre-commit

This auto-generated definition file strategy allows different images to rely on shared code without relying on sequential builds which would be slow and also harder to figure out all the code that was used to create an image.

Note that github action build jobs will fail if the definition file isn't detected to be the exact result of the pasted-together contents of build_scripts. This ensures everyone uses the pre-commit hooks and mitigates the consequences of accidental direct editing of the definition files.

Note that the pre-commit hook calls an R script, so this is a local dependency as well as in the action where that script is run again to ensure it had been run as a pre-commit hook.

Automated definition file creation

During the pre-commit hook, create_def_files.R (stored in the githooks directory) pastes together the contents of the build_scripts directory in the following way to create definition files:

Building images

This repo uses github actions to build images. There are three triggers:

A couple more notes:

Inspiration for this repo, along with more complicated examples for building multiple images can be found here: https://github.com/singularityhub/github-ci