RStudio Server Guide

Revision as of 05:34, 7 September 2024 by Maintenance script (talk | contribs) (Initial)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Return to server-guides Return to research # Rstudio Server Guide

Based on the Rstudio Guide. This guide is designed to help you start with RStudio Server, a web-based interface for R programming. RStudio Server allows you to run R and RStudio in a web browser, providing a flexible and accessible data analysis and visualization environment. This guide covers the installation and configuration of RStudio Server, as well as essential commands and examples for data analysis.

See the source for more information here

Download the rstudio server for docker:

<syntaxhighlight lang="shell">docker pull rocker/rstudio</syntaxhighlight> Create a Dockerfile: Include necessary system dependencies and R packages

<syntaxhighlight lang="dockerfile">FROM rocker/rstudio

RUN apt clean all && \

   apt update && \
   apt upgrade -y && \
   apt install -y \
       libhdf5-dev \
       libcurl4-gnutls-dev \
       libssl-dev \
       libxml2-dev \
       libpng-dev \
       libxt-dev \
       zlib1g-dev \
       libbz2-dev \
       liblzma-dev \
       libglpk40 \
       libgit2-dev \
   && apt clean all && \
   apt purge && \
   rm -rf /var/lib/apt/lists/ /tmp/ /var/tmp/

RUN Rscript -e "install.packages(c('rmarkdown', 'tidyverse', 'workflowr', 'shiny', 'blogdown', 'bookdown', 'learnr', 'xaringan', 'rticles', 'pkgdown', 'devtools', 'usethis', 'testthat', 'roxygen', 'rhub', 'covr', 'rmarkdown', 'knitr', 'dplyr', 'readr', 'packrat', 'rsconnect'))"

the rstudio/ path is set for building with GitHub Actions

WORKDIR /home/rstudio</syntaxhighlight> Build Your Image

<syntaxhighlight lang="shell">docker build -t my-rstudio .</syntaxhighlight> Run Your Custom Container

<syntaxhighlight lang="shell">docker run -d -p 8787:8787 -e PASSWORD=yourpassword my-rstudio</syntaxhighlight> You may also consider running multiple servers to maintain isolation:

<syntaxhighlight lang="shell">docker run -d -p 8788:8787 -e USER=user1 -e PASSWORD=user1password my-rstudio docker run -d -p 8789:8787 -e USER=user2 -e PASSWORD=user2password my-rstudio</syntaxhighlight> Combined commands without comments

<syntaxhighlight lang="shell">docker pull rocker/rstudio touch Dockerfile echo "FROM rocker/rstudio" >> Dockerfile echo "RUN apt clean all && \\" >> Dockerfile echo " apt update && \\" >> Dockerfile echo " apt upgrade -y && \\" >> Dockerfile echo " apt install -y \\" >> Dockerfile echo " libhdf5-dev \\" >> Dockerfile echo " libcurl4-gnutls-dev \\" >> Dockerfile echo " libssl-dev \\" >> Dockerfile echo " libxml2-dev \\" >> Dockerfile echo " libpng-dev \\" >> Dockerfile echo " libxt-dev \\" >> Dockerfile echo " zlib1g-dev \\" >> Dockerfile echo " libbz2-dev \\" >> Dockerfile echo " liblzma-dev \\" >> Dockerfile echo " libglpk40 \\" >> Dockerfile echo " libgit2-dev \\" >> Dockerfile echo " && apt clean all && \\" >> Dockerfile echo " apt purge && \\" >> Dockerfile echo " rm -rf /var/lib/apt/lists/ /tmp/ /var/tmp/" >> Dockerfile echo "RUN Rscript -e \"install.packages(c('rmarkdown', 'tidyverse', 'workflowr', 'shiny', 'blogdown', 'bookdown', 'learnr', 'xaringan', 'rticles', 'pkgdown', 'devtools', 'usethis', 'testthat', 'roxygen', 'rhub', 'covr', 'rmarkdown', 'knitr', 'dplyr', 'readr', 'packrat', 'rsconnect'))\"" >> Dockerfile echo "WORKDIR /home/rstudio" >> Dockerfile docker build -t my-rstudio . docker run -d -p 8787:8787 -e PASSWORD=yourpassword my-rstudio</syntaxhighlight>