From 712b3a09d18a848ae0fc40a5786169b52f204b92 Mon Sep 17 00:00:00 2001 From: josueneo <josue.balbuena@gmail.com> Date: Thu, 27 Apr 2023 00:03:03 -0600 Subject: [PATCH 1/2] Updating to RStudio 2023 --- lang/RStudio/README.md | 49 +++++++++++++++++++++++++--------------- lang/RStudio/RStudio.def | 24 ++++++++++---------- 2 files changed, 43 insertions(+), 30 deletions(-) diff --git a/lang/RStudio/README.md b/lang/RStudio/README.md index dad1afe1..79f56079 100644 --- a/lang/RStudio/README.md +++ b/lang/RStudio/README.md @@ -1,43 +1,56 @@ # RStudio -RStudio is an Integrated Development Environment (IDE) for the R language. By containerizing RStudio, a scientist can leverage the reproducibility and portability of the Singularity platform, allowing them to build data visualizations and analysis tools and ensure that they behave exactly the same in a new environment. +RStudio is an Integrated Development Environment (IDE) for the R language. By containerizing RStudio, a scientist can leverage the reproducibility and portability of the Singularity platform, allowing them to build data visualizations and analysis tools and ensure that they behave exactly the same in a new environment. The definiton file affords some flexibility, allowing you to run RStudio several different ways: -## Instance: +## Instance + This will start up rstudio-server, on default port of 8787 -```$ singularity instance start rstudio.sif rs``` +```bash +singularity instance start \ + --bind run:/run,var-lib-rstudio-server:/var/lib/rstudio-server \ + RStudio.sif rs --server-user=$(whoami) --www-address=0.0.0.0 +``` + +## Run -## Run: This will run rstudio IDE -```$ singularity run rstudio.sif``` +```bash +singularity run rstudio.sif +``` + +## Exec -## Exec: Any program in the container, but specifically for running R directly. -```$ singularity exec rstudio.sif R -f myfile.r``` +```bash +singularity exec rstudio.sif R -f myfile.r +``` To build the image run: -```$ sudo singularity build rstudio.sif RStudio.def``` +```bash +sudo singularity build rstudio.sif RStudio.def +``` When you use run for the IDE, you may need to execute it like: - -```$ SINGULARITYENV_DISPLAY=${DISPLAY} \ - singularity run rstudio.sif``` +```bash +SINGULARITYENV_DISPLAY=${DISPLAY} \ + singularity run rstudio.sif +``` This is needed only if the `DISPLAY` environment variable does not automatically propagate from your host environment to the container. -For a modification of rstudio-server, you can create a `rstudio.conf` file, and bind mount it into the container. For example to run on port 9999: - +For a modification of rstudio-server, for example to run on port 9999: -```$ echo "www-port=9999" > rserver.conf -$ singularity instance start \ - -B rserver.conf:/etc/rstudio/rserver.conf \ - rstudio.sif rs``` +```bash +singularity instance start \ + --bind run:/run,var-lib-rstudio-server:/var/lib/rstudio-server \ + RStudio.sif rs --server-user=$(whoami) --www-address=0.0.0.0 --www-port=9999 +``` You will then access your rstudio-server instance at: [http://localhost:9999](http://localhost:9999) - diff --git a/lang/RStudio/RStudio.def b/lang/RStudio/RStudio.def index a0fdb698..fe8768aa 100644 --- a/lang/RStudio/RStudio.def +++ b/lang/RStudio/RStudio.def @@ -1,5 +1,5 @@ Bootstrap: library -From: debian:9 +From: debian:10 %environment LC_ALL="C" @@ -7,15 +7,16 @@ From: debian:9 %post apt-get update - apt-get -y install systemd systemd-sysv gdebi-core procps libssl1.1 ed wget curl libqt5webkit5 libqt5core5a - apt-get -y install r-base r-base-dev + apt -y install systemd systemd-sysv gdebi-core procps libssl1.1 libnss3 \ + libasound2 ed wget curl libqt5webkit5 libqt5core5a r-base r-base-dev - curl https://download1.rstudio.org/rstudio-xenial-1.1.456-amd64.deb > /rstudio-1.1.456-amd64.deb - apt-get -y install /rstudio-1.1.456-amd64.deb + wget -O /rstudio-2023.03.0-386-amd64.deb \ + https://download1.rstudio.org/electron/bionic/amd64/rstudio-2023.03.0-386-amd64.deb + apt -y install /rstudio-2023.03.0-386-amd64.deb - wget -O /rstudio-server-stretch-1.1.456-amd64.deb \ - https://download2.rstudio.org/rstudio-server-stretch-1.1.456-amd64.deb - gdebi -n /rstudio-server-stretch-1.1.456-amd64.deb + wget -O /rstudio-server-2023.03.0-386-amd64.deb \ + https://download2.rstudio.org/server/bionic/amd64/rstudio-server-2023.03.0-386-amd64.deb + gdebi -n /rstudio-server-2023.03.0-386-amd64.deb # Setup the "general" CRAN repo echo 'local({ @@ -34,12 +35,11 @@ From: debian:9 systemctl enable rstudio-server # Remove unneeded source packages - rm -f /rstudio-1.1.456-amd64.deb - rm -f /rstudio-server-stretch-1.1.456-amd64.deb + rm -f /rstudio-2023.03.0-386-amd64.deb + rm -f /rstudio-server-2023.03.0-386-amd64.deb %runscript /usr/bin/rstudio "$@" %startscript - /usr/lib/rstudio-server/bin/rserver - + /usr/lib/rstudio-server/bin/rserver "$@" From 0ac71b5a508fb4233135ebc47d6664b239b25f86 Mon Sep 17 00:00:00 2001 From: Josue Balbuena <josue.balbuena@gmail.com> Date: Tue, 9 May 2023 13:22:44 -0600 Subject: [PATCH 2/2] Removing DISPLAY, switching to Ubuntu 22.04, removing useradd. --- lang/RStudio/README.md | 2 -- lang/RStudio/RStudio.def | 42 +++++++++++++++++++++++----------------- 2 files changed, 24 insertions(+), 20 deletions(-) diff --git a/lang/RStudio/README.md b/lang/RStudio/README.md index 79f56079..22957b6e 100644 --- a/lang/RStudio/README.md +++ b/lang/RStudio/README.md @@ -43,8 +43,6 @@ SINGULARITYENV_DISPLAY=${DISPLAY} \ singularity run rstudio.sif ``` -This is needed only if the `DISPLAY` environment variable does not automatically propagate from your host environment to the container. - For a modification of rstudio-server, for example to run on port 9999: ```bash diff --git a/lang/RStudio/RStudio.def b/lang/RStudio/RStudio.def index fe8768aa..468fbb5f 100644 --- a/lang/RStudio/RStudio.def +++ b/lang/RStudio/RStudio.def @@ -1,23 +1,36 @@ Bootstrap: library -From: debian:10 +From: ubuntu:22.04 %environment - LC_ALL="C" + LANG=en_US.UTF-8 + LC_ALL="en_US.UTF-8" + export LANG export LC_ALL %post - apt-get update - apt -y install systemd systemd-sysv gdebi-core procps libssl1.1 libnss3 \ - libasound2 ed wget curl libqt5webkit5 libqt5core5a r-base r-base-dev + export DEBIAN_FRONTEND=noninteractive + export TZ=Etc/UTC + apt update -qq + apt install -y --no-install-recommends software-properties-common dirmngr wget locales + + 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 -y "deb https://cloud.r-project.org/bin/linux/ubuntu $(lsb_release -cs)-cran40/" + apt install -y --no-install-recommends r-base r-base-dev wget -O /rstudio-2023.03.0-386-amd64.deb \ - https://download1.rstudio.org/electron/bionic/amd64/rstudio-2023.03.0-386-amd64.deb + https://download1.rstudio.org/electron/jammy/amd64/rstudio-2023.03.0-386-amd64.deb apt -y install /rstudio-2023.03.0-386-amd64.deb wget -O /rstudio-server-2023.03.0-386-amd64.deb \ - https://download2.rstudio.org/server/bionic/amd64/rstudio-server-2023.03.0-386-amd64.deb + https://download2.rstudio.org/server/jammy/amd64/rstudio-server-2023.03.0-386-amd64.deb + apt install -y gdebi-core gdebi -n /rstudio-server-2023.03.0-386-amd64.deb + # Log to stderr + echo "[*]\nlog-level=error\nlogger-type=stderr\n" > /etc/rstudio/logging.conf + # Setup the "general" CRAN repo echo 'local({ r <- getOption("repos") @@ -25,21 +38,14 @@ From: debian:10 options(repos = r) })' >> /etc/R/Rprofile.site - # We are setting up a normal user for access - # Login: rstudio Password: rstudio - useradd -c "RStudio Account" -u 500 -d /home/rstudio -s /bin/bash rstudio - echo "rstudio:rstudio" | /usr/sbin/chpasswd - - # Move systemd service file into place - cp /usr/lib/rstudio-server/extras/systemd/rstudio-server.service /lib/systemd/system/ - systemctl enable rstudio-server + # Prepare system to use UTF-8 + sed -i '/en_US.UTF-8/s/^# //g' /etc/locale.gen && locale-gen && update-locale # Remove unneeded source packages - rm -f /rstudio-2023.03.0-386-amd64.deb - rm -f /rstudio-server-2023.03.0-386-amd64.deb + rm -f /rstudio*.deb %runscript /usr/bin/rstudio "$@" %startscript - /usr/lib/rstudio-server/bin/rserver "$@" + /usr/lib/rstudio-server/bin/rserver --server-user=$(whoami)"$@"