J.U.S.T. Singularity Functions

just_singularity_functions.bsh
singular_defaultify
just singularity import

Converts a docker image to a singularity image, writing the image to the just directory.

Arguments:

… - Same as docker2singularity, mainly “docker image name”

Parameters:
  • SINGULARITY_CUSTOM_IMPORT_SCRIPT - Specifies custom script to use run (step 8.5). This is useful for customizing the image (like entrypoints) before it is converted to a file.

  • SINGULARITY_DOCKER_SOCKET - An array to specify a custom docker socket to connect to docker. If SINGULARITY_DOCKER_SOCKET is not an array, it is converted to an array where whitespaces will be split. Default: (--mount source=/var/run/docker.sock,destination=/var/run/docker.sock,type=bind)

  • DOCKER2SINGULARITY_VERSION - Version of singularity to use docker2singularity. Default: 2.6 for increased compatibility.

just singularity exec
just singularity instance-start
just singularity run
just singularity shell
just singularity test

Starts a singularity container using singularity_functions.bsh Singularity.

just singular-compose

singular-compose take the equivalent place of docker compose, but for singularity. This does not use singularity-compose, instead it is a much simpler and plainer bash version.

Arguments:

[-f {filename} | --file {filename}] - Optionally specify one or more singular-compose files, and ignoring the default found singular-compose.env file.

A singular-compose file (default singular-compose.env) is written 100% in bash and gives you the freedom to do anything you need in it. It is designed to be sourced by singular-compose and has few requirements.

  • instances - must be an array of names of instances. If an instance name is not included here, it will be ignored by singular-compose. You should use the += operator when setting instances, so that multiple files can work together

  • {instance_name}_image - The filename of the singularity image.

  • [{instance_name}_volumes] - An array of bind mounts that will have the -B flag added to them.

  • [{instance_name}_environment] - A paired array of key/value pairs of environment variables that will be set in the singularity container. Even indexes are keys, odd indexes are values (if contiguous).

  • [{instance_name}_singular_flags] - List of extra flags to be passed to the singularity subcommand.

Example singular-compose.env

singular-compose.env
instances+=(django mysql)

# I can even include other compose files
source "${DJANGO_SOURCE_DIR}/singular-compose2.env"

django_environment=(
  TZ "${TZ}"
  DISPLAY "${DISPLAY}"
  JUSTFILE /src/docker/django.Justfile
  JUST_SETTINGS /src/django.env
)
django_volumes=(
  "${DJANGO_SOURCE_DIR}:${DJANGO_INSTALL_DIR_DOCKER}:ro"
  "${VSI_COMMON_DIR}:/vsi:ro"
)
django_singular_flags=(-c -e --nv)
: ${django_image=${DJANGO_CWD}/django_${DJANGO_USERNAME}.simg}

# I can even just copy other arrays (like an anchor)
mysql_environment=("${django_environment[@]}")
# Add a data dir, but copy all but the first volume from django
mysql_volumes=(
  "${DJANGO_SOURCE_DIR}/singular/data:/data:rw"
  "${django_volumes[@]:1}"
)
mysql_singular_flags=("${django_singular_flags[@]}")
: ${mysql_image=${DJANGO_CWD}/mysql_${DJANGO_USERNAME}.simg}

singular-compose currently supports a few subcommands: