TITLE: How to dockerize an R Shiny App
AUTHORS: Sonia García-Ruiz

[DESCRIPTION]
<div class = "text-blocks"><div class = "text-block"><span>This protocol contains the steps to dockerize an R Shiny App. The Shiny App used as an example is vizER (</span><a href="https://rytenlab.com/browser/app/vizER" style = "text-decoration:underline;color:blue;cursor:pointer;"><span style = ":;">https://rytenlab.com/browser/app/vizER</span></a><span>), a platform that enables the visualisation of individual genes for evidence of reannotation developed by the RytenLab team (</span><a href="https://rytenlab.com" style = "text-decoration:underline;color:blue;cursor:pointer;"><span style = ":;">https://rytenlab.com/</span></a><span>).</span></div><div class = "text-block"><span>vizER was released as part of the publication </span><a href="https://advances.sciencemag.org/content/6/24/eaay8299.full" style = "text-decoration:underline;color:blue;cursor:pointer;"><span style = ":;font-style:italic;">Incomplete annotation has a disproportionate impact on our understanding of Mendelian and complex neurogenetic disorders</span></a></div></div>

[STEPS]
?. [Docker installation]
Make sure you have Docker Engine installed on your Operating System. To install it on CentOS: https://docs.docker.com/engine/install/centos/
?. [Docker installation]
Prepare the R Shiny App you would like to dockerize. In this example, we are going to use vizER, which can be downloaded from https://github.com/SoniaRuiz/vizer.git clone https://github.com/SoniaRuiz/vizer.git
?. [Docker installation]
Create a Dockerfile and place it within your app folder, in this example within "./vizER".A Dockerfile is a plain-text and extensionless file, which contains a set of instructions to create a Docker image. The example shown below contains the following commands:FROM: indicates the base docker image to be used. This pre-existing image contains the installation of the operating system Linux with a basic R environment configuration.RUN apt-get update && apt-get install, indicates the set of dependencies to be installed. These will be all R packages that vizER may need during its execution time.COPY, indicates the local files and folders to be copied into the Docker image.RUN mkdir, which indicates the folder to be created to contain all vizER's data dependencies. In this case, these data dependencies are too large to be copied within the Docker image; instead, they will be mounted in the indicated folder during the Docker image execution.CMD: R command to execute the Shiny App.FROM openanalytics/r-baseMAINTAINER Sonia Garcia-Ruiz "s.ruiz@ucl.ac.uk"RUN apt-get update && apt-get install -y --no-install-recommends \	libxt-dev \	libcairo2-dev \        libxml2-dev \        libssl-dev \        libcurl4-openssl-dev \        libv8-3.14-dev \        libsqlite3-dev \        libmariadb-client-lgpl-dev \		&& rm -rf /var/lib/apt/lists/* \		&& R -e "install.packages(c('shiny','rmarkdown','ggpubr','shinyjs','openssl','httr','DT', 'RMySQL','tidyverse','RSQLite'), repos='http://cran.rstudio.com/', dependencies=T)" \		&& R -e "source('https://bioconductor.org/biocLite.R'); biocLite('biomaRt'); biocLite('GenomicFeatures'); biocLite('Gviz'); biocLite('regioneR'); biocLite('GenomicScores')" \		&& mkdir /root/vizERCOPY vizER /root/vizERCOPY Rprofile.site /usr/lib/R/etc/RUN mkdir /root/vizER/vizER_dataEXPOSE 3838CMD ["R", "-e", "shiny::runApp('/root/vizER')"]
?. [Docker installation]
Once the Dockerfile has been created, we need to build the Docker image. Please, be aware that before running this command, it is essential to be located within the same folder containing both the Dockerfile and the ShinyApp files (app.R, ui.R, server.R files, etc.):sudo docker build -t vizER .
?. [Docker installation]
Finally, we run the docker image:sudo docker run -p 3838:3838 vizERTo include the dependencies folder:sudo docker run --rm -p 3838:3838 \    -v ./thedependenciesfolder:/root/vizER/vizER_data/ \    vizER