socket/tunel-django

Launcher: singularity

An example Django application run via a Singularity container.

Usage

$ tunel run-app <server> socket/tunel-django

Arguments

Name Description Split By
user username for logging into Django app (NOT your cluster username), defaults to tunel-user NA
pass password for logging in to Django app (NOT your cluster password), defaults to tunel-pass NA
workdir Working directory for app (and to show file explorer for) NA
container Change the app container used (default is demo ghcr.io/tunel-apps/tunel-django). Must start with container URI to pull (e.g., docker://) NA
tag Tag of the container to use (defaults to latest) NA
pull force a new pull (even if the container already exists). NA


If split by is provided, this means the argument takes a list, and you should use this as a delimiter.

Needs

  • socket

Examples

# Run app on login node with singularity, custom tag dev
tunel run-app waffles singularity/socket/tunel-django --tag=dev
# Force a new pull
tunel run-app waffles singularity/socket/tunel-django --tag=dev --pull
# Set a custom user/password (note that the UI is only available to you so this is not for security)
tunel run-app waffles singularity/socket/tunel-django --tag=dev --user=hello --pass=moto  

Scripts

app.sh

This app uses the singularity launcher by default, and supports the following:

  • slurm
  • docker
  • podman
  • singularity
#!/bin/bash

JOB_NAME="{{ jobname }}"
SOCKET_DIR="{{ scriptdir }}"
mkdir -p ${SOCKET_DIR}

# Include Singularity cachedir if not set
{% include "bash/singularity/set-cache-tmp.sh" %}

# Source ~/bash_profile or ~/.profile
{% include "bash/source-profile.sh" %}

# Set WORKDIR, first to args.workdir, then settings.yml workdir, then $HOME
{% include "bash/set-workdir.sh" %}
cd $WORKDIR

echo "Job is ${JOB_NAME}"
echo "Socket directory is ${SOCKET_DIR}"
echo "App working directory is ${WORKDIR}"

# Create .local folder for default modules, if doesn't exist
{% include "bash/python/create-local.sh" %}

# Remove socket if exists
{% include "bash/socket/set-socket.sh" %}

# Bind the database
DB_DIR=${SOCKET_DIR}/db
STATIC_DIR=${SOCKET_DIR}/static

# username and password for django to create
{% include "bash/set-user-pass.sh" %}

# Load modules requested by user
{% for module in args.modules %}module load {{ module }} || printf "Could not load {{ module }}\n"
{% endfor %}

# Add variables to PATH
{% for path in paths %}export PATH={{ path }}:${PATH}
{% endfor %}

{% if docker %}{% include "templates/run_docker.sh" %}{% else %}{% include "templates/run_singularity.sh" %}{% endif %}

Have any questions, or want to request a new app or launcher? Ask us!