Image size: 4.9 GB

For more on pulling from the registry, see the ilifu documentation.

First, once: add the registry and make it your default

singularity remote add --no-login idia-registry https://sregistry.idia.ac.za
singularity remote use idia-registry

If you added it before, as the ilifu docs describe, remote add says it already exists: just run remote use.

Log in, for a private collection

singularity remote login idia-registry

Paste a token from your token page when asked. Public collections need no login.

Pull the container

singularity pull library://rstudio/r4.6.2:sha256.21a84dd3eeff12b7ed41cd8306b0b4d13ae0a91f7a7d02e01c78543a75973a6e

Shell into the container

singularity shell library://rstudio/r4.6.2:sha256.21a84dd3eeff12b7ed41cd8306b0b4d13ae0a91f7a7d02e01c78543a75973a6e

Run the container

singularity run library://rstudio/r4.6.2:sha256.21a84dd3eeff12b7ed41cd8306b0b4d13ae0a91f7a7d02e01c78543a75973a6e

First, once: add the registry and make it your default

apptainer remote add --no-login idia-registry https://sregistry.idia.ac.za
apptainer remote use idia-registry

If you added it before, as the ilifu docs describe, remote add says it already exists: just run remote use.

Log in, for a private collection

apptainer remote login idia-registry

Paste a token from your token page when asked. Public collections need no login.

Pull the container

apptainer pull library://rstudio/r4.6.2:sha256.21a84dd3eeff12b7ed41cd8306b0b4d13ae0a91f7a7d02e01c78543a75973a6e

Shell into the container

apptainer shell library://rstudio/r4.6.2:sha256.21a84dd3eeff12b7ed41cd8306b0b4d13ae0a91f7a7d02e01c78543a75973a6e

Run the container

apptainer run library://rstudio/r4.6.2:sha256.21a84dd3eeff12b7ed41cd8306b0b4d13ae0a91f7a7d02e01c78543a75973a6e
RStudio Server 2026.10.1+239 by Posit (https://posit.co/products/open-source/rstudio-server/)
with R 4.6.2 by the R Core Team (https://www.r-project.org/), plus tidyverse, devtools,
shiny, rmarkdown and Bioconductor's DESeq2, edgeR, limma, methylKit, bsseq and MethylSeekR.
IDIA packages the unmodified upstream releases.

Apps: R, Rscript and rstudio (also the default runscript). See each app's help.

RStudio Server is licensed under the AGPLv3 and R under the GPL. The licence texts and
source details are in /usr/lib/rstudio-server/COPYING and SOURCE, and in /usr/share/R/doc;
the source code is linked from this image's RStudio_Source and R_Source labels.

This image has 3 apps. Pick one to see how to use it.

singularity run --app R library://rstudio/r4.6.2:sha256.21a84dd3eeff12b7ed41cd8306b0b4d13ae0a91f7a7d02e01c78543a75973a6e

This works once you've added the registry as a remote (see the CLI tab). Add the app's arguments after the command. With Apptainer, start it with apptainer instead.

Help

An interactive R 4.6.2 session.

  singularity run --app R r4.6.2_2026.10.1-239.sif

install.packages() offers to create a personal library in
~/R/x86_64-pc-linux-gnu-library/4.6, which every R 4.6.x image shares. /library is also on
the library path, so a shared package library can be bound there:

  singularity run --bind /path/to/rlib:/library --app R r4.6.2_2026.10.1-239.sif

If installing a package fails on a shared filesystem, try export R_INSTALL_STAGED=false.

Docs: https://cran.r-project.org/manuals.html

Runs

exec R "${@}"
singularity run --app Rscript library://rstudio/r4.6.2:sha256.21a84dd3eeff12b7ed41cd8306b0b4d13ae0a91f7a7d02e01c78543a75973a6e

This works once you've added the registry as a remote (see the CLI tab). Add the app's arguments after the command. With Apptainer, start it with apptainer instead.

Help

Runs an R script non-interactively, e.g. in a Slurm batch job. Arguments after the script
reach it through commandArgs(trailingOnly = TRUE).

  singularity run --app Rscript r4.6.2_2026.10.1-239.sif analysis.R counts.csv

parallel::detectCores() reports every core on the node, not your allocation; in a job, size
workers from the SLURM_CPUS_PER_TASK environment variable instead.

Docs: https://cran.r-project.org/manuals.html

Runs

exec Rscript "${@}"
singularity run --app rstudio library://rstudio/r4.6.2:sha256.21a84dd3eeff12b7ed41cd8306b0b4d13ae0a91f7a7d02e01c78543a75973a6e

This works once you've added the registry as a remote (see the CLI tab). Add the app's arguments after the command. With Apptainer, start it with apptainer instead.

Help

RStudio Server in your browser, running as you on the node you start it on. Start it in a
Slurm job rather than on a login node:

  srun --cpus-per-task=4 --mem=16G --time=08:00:00 --pty \
    singularity run --app rstudio r4.6.2_2026.10.1-239.sif

It picks a free port and prints the ssh tunnel to run on your own machine, which jumps
through the cluster's login node to the compute node:

  ssh -J you@login-node -L 8081:localhost:PORT you@compute-node

On ilifu the login node is slurm.ilifu.ac.za. Set RSTUDIO_LOGIN_HOST to your login node and
the command is printed ready to paste. If the login node doesn't allow -J, use
-o ProxyCommand="ssh you@login-node nc %h 22" in its place.

Then open http://localhost:8081 and sign in with your username and RSTUDIO_PASSWORD. If
RSTUDIO_PASSWORD isn't set, a random password is generated and printed.

The server keeps its state (session data, cookie key, database) in ~/.RStudio.rserver, so
no bind mounts are needed. Extra arguments go to rserver, e.g. --www-address=127.0.0.1 to
accept only tunnelled connections.

Docs: https://docs.posit.co/ide/user/

Runs

exec /usr/local/bin/rstudio "${@}"
Bootstrap: library
Library: https://sregistry.idia.ac.za
From: ci-bot/ubuntu/noble-compile:0.3

%labels
  Maintainer IDIA <support@ilifu.ac.za>
  R_Version 4.6.2
  RStudio_Version 2026.10.1-239
  RStudio_Source https://github.com/rstudio/rstudio/tree/v2026.10.1+239
  R_Source https://cran.r-project.org/src/base/R-4/R-4.6.2.tar.gz

%help
  RStudio Server 2026.10.1+239 by Posit (https://posit.co/products/open-source/rstudio-server/)
  with R 4.6.2 by the R Core Team (https://www.r-project.org/), plus tidyverse, devtools,
  shiny, rmarkdown and Bioconductor's DESeq2, edgeR, limma, methylKit, bsseq and MethylSeekR.
  IDIA packages the unmodified upstream releases.

  Apps: R, Rscript and rstudio (also the default runscript). See each app's help.

  RStudio Server is licensed under the AGPLv3 and R under the GPL. The licence texts and
  source details are in /usr/lib/rstudio-server/COPYING and SOURCE, and in /usr/share/R/doc;
  the source code is linked from this image's RStudio_Source and R_Source labels.

%apprun R
  exec R "${@}"

%apphelp R
  An interactive R 4.6.2 session.

    singularity run --app R r4.6.2_2026.10.1-239.sif

  install.packages() offers to create a personal library in
  ~/R/x86_64-pc-linux-gnu-library/4.6, which every R 4.6.x image shares. /library is also on
  the library path, so a shared package library can be bound there:

    singularity run --bind /path/to/rlib:/library --app R r4.6.2_2026.10.1-239.sif

  If installing a package fails on a shared filesystem, try export R_INSTALL_STAGED=false.

  Docs: https://cran.r-project.org/manuals.html

%apprun Rscript
  exec Rscript "${@}"

%apphelp Rscript
  Runs an R script non-interactively, e.g. in a Slurm batch job. Arguments after the script
  reach it through commandArgs(trailingOnly = TRUE).

    singularity run --app Rscript r4.6.2_2026.10.1-239.sif analysis.R counts.csv

  parallel::detectCores() reports every core on the node, not your allocation; in a job, size
  workers from the SLURM_CPUS_PER_TASK environment variable instead.

  Docs: https://cran.r-project.org/manuals.html

%apprun rstudio
  exec /usr/local/bin/rstudio "${@}"

%apphelp rstudio
  RStudio Server in your browser, running as you on the node you start it on. Start it in a
  Slurm job rather than on a login node:

    srun --cpus-per-task=4 --mem=16G --time=08:00:00 --pty \
      singularity run --app rstudio r4.6.2_2026.10.1-239.sif

  It picks a free port and prints the ssh tunnel to run on your own machine, which jumps
  through the cluster's login node to the compute node:

    ssh -J you@login-node -L 8081:localhost:PORT you@compute-node

  On ilifu the login node is slurm.ilifu.ac.za. Set RSTUDIO_LOGIN_HOST to your login node and
  the command is printed ready to paste. If the login node doesn't allow -J, use
  -o ProxyCommand="ssh you@login-node nc %h 22" in its place.

  Then open http://localhost:8081 and sign in with your username and RSTUDIO_PASSWORD. If
  RSTUDIO_PASSWORD isn't set, a random password is generated and printed.

  The server keeps its state (session data, cookie key, database) in ~/.RStudio.rserver, so
  no bind mounts are needed. Extra arguments go to rserver, e.g. --www-address=127.0.0.1 to
  accept only tunnelled connections.

  Docs: https://docs.posit.co/ide/user/

%runscript
  exec /usr/local/bin/rstudio "${@}"

%environment
  export R_VERSION=4.6.2
  export RSTUDIO_VERSION=2026.10.1-239
  export PATH=/usr/lib/rstudio-server/bin:${PATH}

%post
  # Create Installation Directories and export paths. This is needed as part of post.
  # %environment scriptlet does not define these paths during %post, only after.
  export R_VERSION=4.6.2
  export RSTUDIO_VERSION=2026.10.1-239
  export DEBIAN_FRONTEND=noninteractive

  # The base image's sources.list has only the release pocket, so without these the
  # upgrade below finds no updates.
  . /etc/os-release
  echo "deb http://us.archive.ubuntu.com/ubuntu ${VERSION_CODENAME}-updates main restricted universe" >> /etc/apt/sources.list
  echo "deb http://security.ubuntu.com/ubuntu ${VERSION_CODENAME}-security main restricted universe" >> /etc/apt/sources.list

  # Update apt
  apt-get update -y && apt-get upgrade -y && apt-get dist-upgrade -y
  apt-get install -y \
    apt-utils \
    build-essential \
    dirmngr \
    git \
    imagemagick \
    libfribidi-dev \
    libharfbuzz-dev \
    pandoc \
    python-is-python3 \
    pkg-config \
    texlive \
    texlive-extra-utils \
    texlive-fonts-extra \
    texlive-latex-extra \
    texlive-pictures \
    texlive-pstricks \
    texlive-publishers \
    texlive-science \
    texlive-xetex \
    ca-certificates \
    gdebi-core \
    systemd \
    wget \

  # Add R repositories
  wget -qO- https://cloud.r-project.org/bin/linux/ubuntu/marutter_pubkey.asc | tee -a /etc/apt/trusted.gpg.d/cran_ubuntu_key.asc
  add-apt-repository "deb https://cloud.r-project.org/bin/linux/ubuntu $(lsb_release -cs)-cran40/"

  apt update

# Install R and requirements
  apt-get install -y --no-install-recommends \
    ca-certificates \
    gdebi-core \
    hdf5-tools \
    libcairo2-dev \
    libcurl4-openssl-dev \
    libfontconfig-dev \
    libfreetype-dev \
    libfribidi-bin \
    libfribidi-dev \
    libgit2-dev \
    libgsl27 \
    libgsl-dev \
    libharfbuzz-dev \
    libhdf5-dev \
    libjpeg-dev \
    libnetcdf-dev \
    libpng-dev \
    libssl-dev \
    libtiff5-dev \
    libuv1-dev \
    libxml2-dev \
    libxt-dev \
    netcdf-bin \
    patchelf \
    r-base=${R_VERSION}* \
    r-base-core=${R_VERSION}* \
    r-base-dev=${R_VERSION}* \
    r-recommended=${R_VERSION}* \
    r-base-html=${R_VERSION}* \
    r-doc-html=${R_VERSION}* \
    systemd \
    wget \

  apt-mark hold r-base*

  # Add a default CRAN mirror
  echo "options(repos = c(CRAN = 'https://cran.rstudio.com/'), download.file.method = 'libcurl')" >> /usr/lib/R/etc/Rprofile.site

  # Add a directory for host R libraries
  mkdir -p /library
  echo "R_LIBS_SITE=/library:\${R_LIBS_SITE}" >> /usr/lib/R/etc/Renviron.site

  # rserver's --auth-pam-helper: checks the login against RSTUDIO_PASSWORD.
  # Thanks to nickjer for this! https://github.com/nickjer/singularity-rstudio/blob/master/Singularity.3.6.0
  mkdir -p /usr/lib/rstudio-server/bin
  cat > /usr/lib/rstudio-server/bin/rstudio_auth <<'EOF'
#!/usr/bin/env bash

# Confirm username is supplied
if [[ $# -lt 1 ]]; then
  echo "Usage: auth USERNAME"
  exit 1
fi
USERNAME="${1}"

# Confirm password environment variable exists
if [[ -z "${RSTUDIO_PASSWORD}" ]]; then
  echo "The environment variable RSTUDIO_PASSWORD is not set"
  exit 1
fi

# Read in the password from user
read -s -p "Password: " PASSWORD
echo ""

# Authenticate user
if [[ "${USER}" == "${USERNAME}" && "${PASSWORD}" == "${RSTUDIO_PASSWORD}" ]]; then
  echo "Successful authentication"
  exit 0
else
  echo "Invalid authentication"
  exit 1
fi
EOF
  chmod 755 /usr/lib/rstudio-server/bin/rstudio_auth

  # The rstudio app and the runscript: starts rserver as the calling user and prints how to
  # tunnel to it. rserver's database would otherwise go in /var/lib/rstudio-server, which is
  # read-only in the image, so it's pointed at the same ~/.RStudio.rserver/var/lib that the
  # ilifu module binds there: no binds needed, and both share one database.
  cat > /usr/local/bin/rstudio <<'EOF'
#!/bin/sh
set -e
SERVER_DIR="${HOME}/.RStudio.rserver"
mkdir -p "${SERVER_DIR}/data" "${SERVER_DIR}/var/lib"
printf 'provider=sqlite\ndirectory=%s\n' "${SERVER_DIR}/var/lib" > "${SERVER_DIR}/database.conf"

if [ -z "${RSTUDIO_PASSWORD}" ]; then
  RSTUDIO_PASSWORD=$( tr -cd '[:alnum:]' < /dev/urandom | head -c 30 )
  export RSTUDIO_PASSWORD
  echo "RSTUDIO_PASSWORD was not set, so a password has been chosen for you: ${RSTUDIO_PASSWORD}"
fi
PORT=$( python3 -c 'import socket; s=socket.socket(); s.bind(("", 0)); print(s.getsockname()[1]); s.close()' )
HOST=$( hostname )

echo "Running RStudio Server on ${HOST}, port ${PORT}."
if [ -n "${RSTUDIO_LOGIN_HOST}" ]; then
  echo "To connect, run this on your own machine:"
  echo "    ssh -J ${USER}@${RSTUDIO_LOGIN_HOST} -L 8081:localhost:${PORT} ${USER}@${HOST}"
else
  echo "To connect, run this on your own machine with your cluster's login node in place of"
  echo "LOGIN_NODE (set RSTUDIO_LOGIN_HOST to have it filled in):"
  echo "    ssh -J ${USER}@LOGIN_NODE -L 8081:localhost:${PORT} ${USER}@${HOST}"
  echo "On ilifu, for example:"
  echo "    ssh -J ${USER}@slurm.ilifu.ac.za -L 8081:localhost:${PORT} ${USER}@${HOST}"
fi
echo "Then open http://localhost:8081 and sign in as \"${USER}\" with your RSTUDIO_PASSWORD."
echo "If port 8081 is taken on your machine, use another in both the ssh command and the URL."

exec rserver \
  --server-user "${USER}" \
  --auth-none 0 \
  --auth-pam-helper rstudio_auth \
  --secure-cookie-key-file "${SERVER_DIR}/secure-cookie.key" \
  --server-data-dir "${SERVER_DIR}/data" \
  --database-config-file "${SERVER_DIR}/database.conf" \
  --www-port "${PORT}" \
  "$@"
EOF
  chmod 755 /usr/local/bin/rstudio

  cd /tmp || exit 1
  wget https://download2.rstudio.org/server/jammy/amd64/rstudio-server-${RSTUDIO_VERSION}-amd64.deb
  gdebi -n rstudio-server-${RSTUDIO_VERSION}-amd64.deb
  rm rstudio-server-${RSTUDIO_VERSION}-amd64.deb

  # install a few basics
  Rscript -e 'install.packages(
    c(
      "circlize",
      "data.table",
      "devtools",
      "DBI",
      "gprofiler2",
      "mgcv",
      "nlme",
      "pacman",
      "rmarkdown",
      "Rcpp",
      "shiny",
      "tidyverse",
      "xtable"
    ), Ncpus=parallel::detectCores())'
  Rscript -e 'update.packages(ask=FALSE)'
  Rscript -e 'devtools::install_github("hadley/devtools")'

  mkdir -p /var/run/rstudio-server
  chmod ugo+w /var/run/rstudio-server
  chmod +t /var/run/rstudio-server

  Rscript -e 'install.packages("BiocManager", Ncpus=parallel::detectCores())'
  Rscript -e 'BiocManager::install(ask=FALSE, update=TRUE)'

  Rscript -e 'BiocManager::install(
    pkgs = c("DESeq2", "edgeR", "limma", "MethylSeekR", "methylKit", "bsseq"),
    dependencies = TRUE, Ncpus=parallel::detectCores()
  )'

  Rscript -e 'install.packages(
    pkgs = "bcbioRNASeq",
    repos = c(
        "https://r.acidgenomics.com",
        BiocManager::repositories()
    ),
    dependencies = TRUE, Ncpus=parallel::detectCores()
  )'

  Rscript -e 'install.packages(
    pkgs = "DESeqAnalysis",
    repos = c(
        "https://r.acidgenomics.com",
        BiocManager::repositories()
    ),
    dependencies = TRUE, Ncpus=parallel::detectCores()
  )'

  # Cleanup the container
  apt-get clean
  apt-get autoclean

%test
  R_VERSION=4.6.2
  R --version | grep -q "${R_VERSION}"
  test -x /usr/local/bin/rstudio
Download rstudio-r4.6.2_2026.10.1-239.def
#!/bin/sh

  exec /usr/local/bin/rstudio "${@}"
#!/bin/sh

  R_VERSION=4.6.2
  R --version | grep -q "${R_VERSION}"
  test -x /usr/local/bin/rstudio
# /.singularity.d/env/90-environment.sh
#!/bin/sh
# Custom environment shell code should follow


  export INSTALLER_PATH=/installer
  export SOFTWARE_PATH=/software
  export PATH=${SOFTWARE_PATH}/bin:${PATH}
  export LC_ALL=C
  unset XDG_RUNTIME_DIR



  export INSTALLER_PATH=/installer
  export SOFTWARE_PATH=/software
  export PATH=${SOFTWARE_PATH}/bin:${PATH}
  export LD_LIBRARY_PATH=${SOFTWARE_PATH}/lib:${LD_LIBRARY_PATH}
  export LIBRARY_PATH=${SOFTWARE_PATH}/lib:${LIBRARY_PATH}
  export CPATH=${SOFTWARE_PATH}/include:${CPATH}
  export INCLUDE=${SOFTWARE_PATH}/include/:${INCLUDE}
  export PKG_CONFIG_PATH=${SOFTWARE_PATH}/lib/pkgconfig:${PKG_CONFIG_PATH}

  export LC_ALL=C
  unset XDG_RUNTIME_DIR



  export R_VERSION=4.6.2
  export RSTUDIO_VERSION=2026.10.1-239
  export PATH=/usr/lib/rstudio-server/bin:${PATH}