Last active
June 27, 2023 15:19
-
-
Save hans/fac88800a4381aa4d4e8e3a2e7dcecc5 to your computer and use it in GitHub Desktop.
Dockerfile and Singularity converter script for creating RStudio image for R 4.3.0, RStudio 2023.06
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM ubuntu:20.04 | |
# Software versions | |
ARG R_VERSION=4.3.0 | |
ARG RSTUDIO_VERSION=2023.06.0-421 | |
# Locale configuration | |
RUN apt-get update && apt-get install -y --no-install-recommends locales | |
RUN echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen && \ | |
locale-gen en_US.utf8 && \ | |
/usr/sbin/update-locale LANG=en_US.UTF-8 && \ | |
export LC_ALL=en_US.UTF-8 && \ | |
export LANG=en_US.UTF-8 | |
# Install R | |
RUN apt-get install -y --no-install-recommends \ | |
software-properties-common dirmngr wget && \ | |
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-get install -y --no-install-recommends \ | |
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}* \ | |
libcurl4-openssl-dev \ | |
libssl-dev \ | |
libxml2-dev \ | |
libcairo2-dev \ | |
libxt-dev \ | |
libopenblas-dev | |
# Install some build-expensive packages by Ubuntu package instead | |
RUN add-apt-repository "ppa:c2d4u.team/c2d4u4.0+" && \ | |
apt-get install -y --no-install-recommends \ | |
r-cran-brms \ | |
r-cran-knitr \ | |
r-cran-lme4 \ | |
r-cran-lmertest \ | |
r-cran-plotrix \ | |
r-cran-ggplot2 \ | |
r-cran-devtools | |
# Add a default CRAN mirror | |
RUN 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 | |
RUN mkdir -p /library && \ | |
echo "R_LIBS_SITE=/library:\${R_LIBS_SITE}" >> /usr/lib/R/etc/Renviron.site | |
# Install nice-to-have R packages | |
RUN Rscript -e "install.packages(c('tidyverse'))" | |
# Install RStudio dependencies | |
RUN apt-get install -y --no-install-recommends \ | |
ca-certificates \ | |
wget \ | |
gdebi-core | |
# Install RStudio | |
RUN wget \ | |
--no-verbose \ | |
-O rstudio-server.deb \ | |
"https://download2.rstudio.org/server/focal/amd64/rstudio-server-${RSTUDIO_VERSION}-amd64.deb" && \ | |
gdebi -n rstudio-server.deb && \ | |
rm -f rstudio-server.deb | |
# Clean up | |
RUN rm -rf /var/lib/apt/lists/* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Bootstrap: docker-daemon | |
From: rstudio:latest | |
%help | |
This will run RStudio Server | |
%apprun rserver | |
exec rserver "${@}" | |
%runscript | |
exec rserver "${@}" | |
%environment | |
export PATH=/usr/lib/rstudio-server/bin:${PATH} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment