Deploying Apps

Deploying a Shiny app

ShinyProxy uses one or more Docker images to serve the Shiny apps to end users. If you want to deploy your Shiny apps, you will therefore need to build your own Docker image for the app.

Such a Docker image will typically contain:

  • an R installation with
  • all R packages the Shiny app depends on (‘dependencies’) and
  • a folder which contains the ui.R and server.R for your Shiny app.

Write a Dockerfile

Docker images are built starting from a Dockerfile. The Dockerfile starts from a preexisting image and builds up the image command by command.

In order to simplify writing Dockerfiles for your Shiny apps, Open Analytics made a template available in the shinyproxy-template repository on Github that shows how an app can typically be prepared for deployment on ShinyProxy. The app we will use in the example is named ’euler’ and allows to compute Euler’s number using arbitrary precision. In the repository the relevant ui.R and server.R files live in the folder euler.

In order to make these very precise computations the app uses the Rmpfr package for multiple precision computing

FROM openanalytics/r-base

LABEL maintainer "Tobias Verbeke <>"

# system libraries of general use
RUN apt-get update && apt-get install -y \
    sudo \
    pandoc \
    pandoc-citeproc \
    libcurl4-gnutls-dev \
    libcairo2-dev \
    libxt-dev \
    libssl-dev \
    libssh2-1-dev \

# system library dependency for the euler app
RUN apt-get update && apt-get install -y \

# basic shiny functionality
RUN R -e "install.packages(c('shiny', 'rmarkdown'), repos='')"

# install dependencies of the euler app
RUN R -e "install.packages('Rmpfr', repos='')"

# copy the app to the image
RUN mkdir /root/euler
COPY euler /root/euler

COPY /usr/lib/R/etc/


CMD ["R", "-e", "shiny::runApp('/root/euler')"]

Let’s walk through this Dockerfile step by step:

  • The first line of the Dockerfile simply indicates that the image starts from a pre-built image openanalytics/r-base which has Ubuntu 16.04 LTS with a recent R version. This image is available on (Docker hub)[].
  • the LABEL instruction adds metadata to an image, in this case the maintainer of the Docker image
  • Next, a number of additional system packages are installed from the Ubuntu repository using apt-get install. The ones listed are of general use, but
  • for your applications additional system libraries may be required and can be installed in this way. For clarity we have included the installation of an extra system library in a separate block: the R package Rmpfr requires the system library libmpfr-dev to be available
  • Then, there is a RUN command to install shiny specific R packages that need to be present for Shiny to be functional at all (rmarkdown is included for reporting purposes).
  • The next step is to install any dependencies your specific application may have - in this case the Rmpfr package for multiple-precision computing.
  • Once all dependencies are present, we can copy our euler app (with the ui.R and server.R files) onto the image in folder /root/euler
  • The line that copies the onto the image will make sure your Shiny app will run on the port expected by ShinyProxy and also ensures that one will be able to connect to the Shiny app from the outside world
  • EXPOSE 3838 instructs Docker to expose port 3838 to the outside world (otherwise it will not be possible to connect to the Shiny application)
  • the CMD statement, finally, instructs how to launch the Shiny app when the container is started.

Build the Docker Image

Navigate into the directory that contains the Dockerfile. In our example this is the root folder of our shinyproxy-template GIT repository.

Inside this folder launch the following docker command

sudo docker build -t openanalytics/shinyproxy-template .

to build the docker image.

Configure ShinyProxy

As discussed under Configuration, the configuration of ShinyProxy happens in a single file application.yml. If one wants to add an application, it can be specified in the specs block as follows:

  - id: euler
    display-name: Euler's number
    container-cmd: ["R", "-e", "shiny::runApp('/root/euler')"]
    container-image: openanalytics/shinyproxy-template
    access-groups: scientists

The meaning of the individual fields can be consulted here.

Run ShinyProxy

See Getting Started guide:

java -jar shinyproxy-3.0.2.jar