Skip to main content

R Shiny

This guide provides instructions on how to build a Docker image for an R Shiny application, push it to the Geddes Registry and deploy it on Geddes.

Link to section 'Create an RShiny Docker Image' of 'R Shiny' Create an RShiny Docker Image

Create a local Dockerfile by saving the following Dockerfile to your computer and editing the contents for your R Shiny App.

FROM rocker/shiny

# install R package dependencies
RUN apt-get update && apt-get install -y \
    libssl-dev \
    git \
    ## clean up
    && apt-get clean \
    && rm -rf /var/lib/apt/lists/ \
    && rm -rf /tmp/downloaded_packages/ /tmp/*.rds

## Install any R packages you need
RUN install2.r --error \
        <package 1> \
        <package 2> \
        <package 3> \
    ## clean up
    && rm -rf /tmp/downloaded_packages/ /tmp/*.rds

## copy shiny app to shiny server location
COPY ./<app directory> /srv/shiny-server/

Link to section 'Docker Build and Testing Process' of 'R Shiny' Docker Build and Testing Process

Build the Docker image locally based on the Dockerfile above. The Dockerfile must be in your current working directory. This command tags the image with the name "myshinyapp" and version 1.0.

docker build -t myshinyapp:1.0 .

Test your application locally. This command will run your container locally and expose the R Shiny port (3838) so it can be accessed via http://localhost:3838 in your web browser.

On Linux or Mac: docker run --network=host myshinyapp:1.1

On Windows: docker run -p 3838:3838 myshinyapp:1.1

Iterate on code changes locally until you want to deploy on Geddes.

Link to section 'Tag and Upload to the Geddes Registry' of 'R Shiny' Tag and Upload to the Geddes Registry

Tag the image for upload to the Geddes Registry

docker tag myshiny:1.0 geddes-registry.rcac.purdue.edu/<repo>/myshinyapp:1.0

Push the image to the Geddes Registry. Run the login command using your Purdue career account username and password if you currently are not authenticated to the registry.

docker login geddes-registry.rcac.purdue.edu
docker push geddes-registry.rcac.purdue.edu/<repo>/myshinyapp:1.0

Link to section 'Deploy the Application on Geddes' of 'R Shiny' Deploy the Application on Geddes

To deploy the application, one can follow the instructions for deploying a web server and replace the image name with the Geddes registry image tag from above: geddes-registry.rcac.purdue.edu/<repo>/myshinyapp:1.0

Helpful?

Thanks for letting us know.

Please don't include any personal information in your comment. Maximum character limit is 250.
Characters left: 250
Thanks for your feedback.