Skip to content

Instantly share code, notes, and snippets.

@statwonk
Last active August 29, 2015 14:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save statwonk/7e966b7c6928db4aaba1 to your computer and use it in GitHub Desktop.
Save statwonk/7e966b7c6928db4aaba1 to your computer and use it in GitHub Desktop.

Shiny Server Pro in Docker

This is a Dockerfile for Shiny Server Pro on Ubuntu 14.04. It is based on the rocker-org Shiny image, except that it builds on Ubuntu instead of Debian, and installs Shiny Server Pro instead of Shiny Server.

This Dockerfile also installs some examples from the an old commit of the shiny-examples repo. The purpose of this Dockerfile is to run specific examples that require Shiny Server Pro, and currently can't be run on Shinyapps.io.

NOTE: Building the Docker image requires compiling dplyr, which can consume a lot of memory. If you're running this on a VM, you may need to enable swap for the VM.

Usage:

To build (assuming you're in this directory):

docker build -t ssp-examples .

To run a temporary container with Shiny Server Pro:

docker run --rm -p 3838:3838 ssp-examples

Then you can visit examples at (e.g.):

(If using boot2docker, visit http://192.168.59.103:3838/appdir/.) A full list of the examples is at the shiny-examples repo.

To expose a directory on the host to the container use -v <host_dir>:<container_dir>. The following command will use /srv/shinylog on the host as the directory for logs. Note that if the directories on the host don't already exist, they will be created automatically.

docker run --rm -p 3838:3838 \
    -v /srv/shinylog/:/var/log/ \
    ssp-examples

In a real deployment scenario, you will probably want to run the container in detached mode (-d) and listening on the host's port 80 (-p 80:3838):

docker run -d -p 80:3838 \
    -v /srv/shinylog/:/var/log/ \
    ssp-examples
FROM ubuntu:14.04
MAINTAINER Winston Chang "winston@rstudio.com"
# =====================================================================
# R
# =====================================================================
# Need this to add R repo
RUN apt-get update && apt-get install -y software-properties-common
# Add R apt repository
RUN add-apt-repository "deb http://cran.rstudio.com/bin/linux/ubuntu $(lsb_release -cs)/"
RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E084DAB9
# Install basic stuff and R
RUN apt-get update && apt-get install -y \
vim-tiny \
less \
wget \
r-base \
r-base-dev \
r-recommended
# =====================================================================
# Shiny Server Pro
# =====================================================================
RUN apt-get install -y \
gdebi-core \
pandoc \
pandoc-citeproc \
libcurl4-gnutls-dev \
libcairo2-dev \
libxt-dev
# Download and install libssl 0.9.8
RUN wget --no-verbose http://ftp.us.debian.org/debian/pool/main/o/openssl/libssl0.9.8_0.9.8o-4squeeze14_amd64.deb && \
dpkg -i libssl0.9.8_0.9.8o-4squeeze14_amd64.deb && \
rm -f libssl0.9.8_0.9.8o-4squeeze14_amd64.deb
# Download and install shiny server pro
RUN wget https://s3.amazonaws.com/rstudio-shiny-server-pro-build/ubuntu-12.04/x86_64/VERSION -O "version.txt" && \
VERSION=$(cat version.txt) && \
wget "https://s3.amazonaws.com/rstudio-shiny-server-pro-build/ubuntu-12.04/x86_64/shiny-server-commercial-$VERSION-amd64.deb" -O ssp-latest.deb && \
gdebi -n ssp-latest.deb && \
rm -f version.txt ssp-latest.deb
RUN echo "password" | /opt/shiny-server/bin/sspasswd /etc/shiny-server/passwd "admin"
RUN R -e "install.packages(c('shiny', 'rmarkdown'), repos='http://cran.rstudio.com/')"
EXPOSE 3838
COPY shiny-server.sh /usr/bin/shiny-server.sh
CMD ["/usr/bin/shiny-server.sh"]
# =====================================================================
# Shiny examples
# =====================================================================
# Get examples from git repo. This downloads the files from the commit just
# before Garrett deleted them from the repo:
# https://github.com/rstudio/shiny-examples/commit/41ff00e
RUN cd /srv/shiny-server && \
wget https://github.com/rstudio/shiny-examples/archive/230acb1990f1ea6049885837eac8e58ed8405f80.zip && \
unzip 230acb1990f1ea6049885837eac8e58ed8405f80.zip && \
rm 230acb1990f1ea6049885837eac8e58ed8405f80.zip && \
mv shiny-examples-230acb1990f1ea6049885837eac8e58ed8405f80/* . && \
rm -rf shiny-examples-230acb1990f1ea6049885837eac8e58ed8405f80
# Packages needed for specific examples
RUN R -e "install.packages(c('ggplot2', 'lubridate', 'dplyr', 'RSQLite'), repos='http://cran.rstudio.com/')"
#!/bin/sh
# Make sure the directory for individual app logs exists
mkdir -p /var/log/shiny-server
chown shiny.shiny /var/log/shiny-server
exec shiny-server >> /var/log/shiny-server.log 2>&1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment