Skip to content
Snippets Groups Projects
Commit 5297f4cb authored by Peng Lian's avatar Peng Lian
Browse files

Add RStudio

parent efbc4ef1
Branches
No related merge requests found
FROM rocker/rstudio:4.1.1
LABEL CONTAINER_VERSION="0.0.2" \
AUTHOR="Peng Lian" \
EMAIL="biohpc-help@utsouthwestern.edu"
# build-time varialbes
ARG http_proxy=http://proxy.swmed.edu:3128/
ARG https_proxy=http://proxy.swmed.edu:3128/
ARG no_proxy="*.swmed.edu,*.swmed.org,*.utsouthwestern.edu,localhost,127.0.0.1/8"
ENV http_proxy="${http_proxy}" \
https_proxy="${https_proxy}" \
no_proxy="${no_proxy}"
RUN mkdir /vizapp
# Allow root login. Ref. Section 3.2. https://s3.amazonaws.com/rstudio-server/rstudio-server-pro-0.99.903-admin-guide.pdf
# Usefull for fakeroot function of singularity
RUN /usr/bin/bash -c "sed -i 's/^UID_MIN.*/UID_MIN 0/g' /etc/login.defs"
FROM rocker/rstudio:4.2.2
LABEL CONTAINER_VERSION="0.0.2" \
AUTHOR="Peng Lian" \
EMAIL="biohpc-help@utsouthwestern.edu"
# build-time varialbes
ARG http_proxy=http://proxy.swmed.edu:3128/
ARG https_proxy=http://proxy.swmed.edu:3128/
ARG no_proxy="*.swmed.edu,*.swmed.org,*.utsouthwestern.edu,localhost,127.0.0.1/8"
ENV http_proxy="${http_proxy}" \
https_proxy="${https_proxy}" \
no_proxy="${no_proxy}"
RUN mkdir /vizapp
# Allow root login. Ref. Section 3.2. https://s3.amazonaws.com/rstudio-server/rstudio-server-pro-0.99.903-admin-guide.pdf
# Usefull for fakeroot function of singularity
RUN /usr/bin/bash -c "sed -i 's/^UID_MIN.*/UID_MIN 0/g' /etc/login.defs"
#!/bin/bash
PACKAGE="rstudio"
VERSION="$1"
CONTAINER_TAG="${PACKAGE}:${VERSION}"
CONTAINER_NAME="git.biohpc.swmed.edu:5050/astrocyte/container/${CONTAINER_TAG}"
export DOCKER_BUILDKIT=0
export COMPOSE_DOCKER_CLI_BUILD=0
# build with proxy settings
docker build -f ./${VERSION}/Dockerfile -t ${CONTAINER_TAG} ./${VERSION} &> build_and_push-${VERSION}.log
# docker login
# Please create your person "Acess token" and config the "~/.docker/config.json" to login automatically
# Tag and push
docker tag ${CONTAINER_TAG} ${CONTAINER_NAME}
docker push ${CONTAINER_NAME}
#!/bin/bash
#
# This is an example script to demonstrate how to use an R container to install and run vizapp on a local host with docker.
# root privilege is NOT required.
#
# Author: Peng Lian
#
module load singularity/3.9.9
tmpDir=/tmp/$USER/rstudio
# vizapp folder on the host machine. (Will mount as /vizapp)
VIZAPP_HOME="$tmpDir/vizapp/"
# dependencies libs of vizapp, space seperated
VIZAPP_LIBS="rmarkdown"
# user specified path to install the vizapp libs inside the container
R_LIBS_USER="/vizapp/rlibrary"
# env of the vizapp. (Will mount to /mnt)
outputDir=$(pwd)
# prepare tmp and the library folder
mkdir -p ${VIZAPP_HOME}/rlibrary
mkdir -p $tmpDir/home
mkdir -p $tmpDir/run
mkdir -p $tmpDir/tmp
chmod -R 777 $tmpDir &> /dev/null
# build a soft link from outputDir (mounted as /mnt) to user's home
ln -s /mnt $tmpDir/home/outputDir
# version and the image to use
PACKAGE="rstudio"
VERSION="4.2.2"
IMAGE_NAME="git.biohpc.swmed.edu:5050/astrocyte/container/${PACKAGE}:${VERSION}"
# name of the local image
singularity_image=${PACKAGE}_${VERSION}.sif
# pull the container to a local image
if [ ! -e ${singularity_image} ]; then
singularity pull ${singularity_image} docker://$IMAGE_NAME
fi
# Disable auth or not
DISABLE_AUTH=true
PASSWORD=BioHPC
DEFAULT_USER=root
# install vizapp libs to customize folder
for lib in $VIZAPP_LIBS; do
SINGULARITYENV_R_LIBS_USER=${R_LIBS_USER} \
SINGULARITYENV_DISABLE_AUTH=$DISABLE_AUTH \
SINGULARITYENV_PASSWORD=$PASSWORD \
SINGULARITYENV_DEFAULT_USER=$DEFAULT_USER \
singularity exec -f -C -w -e \
-H $tmpDir/home:/root \
-B $outputDir:/mnt,$VIZAPP_HOME:/vizapp,$tmpDir/tmp:/tmp ${singularity_image} \
R -e "if (!require('$lib', character.only=TRUE)) {install.packages('$lib', dependencies=TRUE, lib='$R_LIBS_USER')}"
done
# run vizapp on localhost
SINGULARITYENV_R_LIBS_USER=${R_LIBS_USER} \
SINGULARITYENV_DISABLE_AUTH=$DISABLE_AUTH \
SINGULARITYENV_PASSWORD=$PASSWORD \
SINGULARITYENV_DEFAULT_USER=$DEFAULT_USER \
singularity run -f -C -w -e \
-H $tmpDir/home:/root \
-B $outputDir:/mnt,$VIZAPP_HOME:/vizapp,$tmpDir/tmp:/tmp ${singularity_image}
## Enable this section if run as non-root user inside the container
## clean up the files created in the container
#SINGULARITYENV_R_LIBS_USER=${R_LIBS_USER} \
#SINGULARITYENV_DISABLE_AUTH=$DISABLE_AUTH \
#SINGULARITYENV_PASSWORD=$PASSWORD \
#SINGULARITYENV_DEFAULT_USER=$DEFAULT_USER \
#singularity exec -f -C -w -e \
#-H $tmpDir/home:/root \
#-B $tmpDir/run:/var/run,$tmpDir/tmp:/tmp ${singularity_image} \
#/bin/bash -c "rm -fr /home/rstudio/* /home/rstudio/.* /var/run/* /tmp/* "
# clean up tmp dir from host
rm -fr $tmpDir
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment