This document contains an example Dockerfile configured for deploying Shiny apps on ShinyProxy. The key is to properly configure the shiny port
and host
.
Sample application structure
app
└───Dockerfile
└───Rprofile.site
└───app.R
Dockerfile
# Start with base image containing R 3.6.1 and tidyverse packages
# DockerHub: https://hub.docker.com/r/rocker/tidyverse
# Other images from Rocker: https://hub.docker.com/u/rocker/
FROM rocker/tidyverse:3.6.3
# Install system dependencies needed for app
RUN apt-get update && apt-get install -y \
\
sudo \
pandoc \
pandoc-citeproc \
libcurl4-gnutls-dev \
libcairo2-dev \
libxt-dev \
libssl-dev \
libssh2-1-dev
libxml2-dev
# Install R packages
RUN R -e "install.packages('remotes', repos='http://cran.rstudio.com')" &&\
-e "remotes::install_version('shiny', version = '1.4.0', repos='http://cran.rstudio.com')" &&\
R -e "install.packages('shinythemes', repos='http://cran.rstudio.com')" &&\
R -e "install.packages('shinyWidgets', repos='http://cran.rstudio.com')" &&\
R
# Copy all contents to the image
RUN mkdir /root/app
COPY . /root/app
# Copy Rprofile.site to the image
COPY Rprofile.site /usr/local/lib/R/etc/
# Expost port 3838 when a container is launched
EXPOSE 3838
# Run the app when a container is launched
CMD ["R", "-e", "shiny::runApp('/root/app', port=3838, host='0.0.0.0')"]
Rprofile.site
local({
options(shiny.port = 3838, shiny.host = "0.0.0.0")
})