Skip to content

Instantly share code, notes, and snippets.

@aarong1
Last active October 9, 2021 20:52
Show Gist options
  • Save aarong1/424ac72dfe7b069e7fb06c4075e61bea to your computer and use it in GitHub Desktop.
Save aarong1/424ac72dfe7b069e7fb06c4075e61bea to your computer and use it in GitHub Desktop.
Boilerplate Rshiny dockerfile. The dependencies are created and stored in the .renv file. This is done by calling renv::init() and renv::snapshot() #renv #shiny-server #r #docker. NB 'storage_app in lines 24 and 26 need changes to your application name. Run from app directory.
# Base image https://hub.docker.com/u/rocker/
FROM rocker/shiny:latest
# system libraries of general use
## install debian packages
RUN apt-get update -qq && apt-get -y --no-install-recommends install \
libxml2-dev \
libcairo2-dev \
libsqlite3-dev \
libmariadbd-dev \
libpq-dev \
libssh2-1-dev \
unixodbc-dev \
libcurl4-openssl-dev \
libssl-dev
## update system libraries
RUN apt-get update && \
apt-get upgrade -y && \
apt-get clean
# copy necessary files
## renv.lock file
COPY /storage_app/renv.lock ./renv.lock
## app folder
COPY /storage_app ./app
# install renv & restore packages
RUN Rscript -e 'install.packages("renv")'
RUN Rscript -e 'renv::restore()'
# expose port
EXPOSE 3838
# run app on container start
CMD ["R", "-e", "shiny::runApp('/app', host = '0.0.0.0', port = 3838)"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment