Skip to content

Instantly share code, notes, and snippets.

@magic-lantern
Created June 9, 2020 22:56
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 magic-lantern/1c9327748f223349a799b698b9e927ef to your computer and use it in GitHub Desktop.
Save magic-lantern/1c9327748f223349a799b698b9e927ef to your computer and use it in GitHub Desktop.
Dockerfile for R testing
# Test of docker build process
#
# ctd - Crash Test Dummy. "You can learn a lot from a dummy"
#
# Sample commnds
# date; docker build --tag ctd:1.0 .; date
# docker history ctd:1.0
# docker run -i -t ctd:1.0 /bin/bash
# this whole thing should take 30 - 35 minutes on first run
FROM rocker/r-ver:3.6.3
# install OS packages
RUN apt-get -qq update && \
apt-get -q install -y libcurl4-openssl-dev libgit2-dev libssl-dev libssh2-1-dev libxml2-dev gawk texlive-latex-base texlive-fonts-extra git qpdf libjpeg-dev libpng-dev > /dev/null && \
rm -rf /var/lib/apt/lists/*
# install R packages
RUN R -e "install.packages('devtools', repo = 'https://cran.rstudio.com', Ncpus = 4)" && \
R -e "options(Ncpus = 4L); devtools::install_cran('DescTools')" && \
R -e "options(Ncpus = 4L); devtools::install_cran('dplyr')" && \
R -e "options(Ncpus = 4L); devtools::install_cran('ggplot2')" && \
R -e "options(Ncpus = 4L); devtools::install_cran('gridExtra')" && \
R -e "options(Ncpus = 4L); devtools::install_cran('Hmisc')" && \
R -e "options(Ncpus = 4L); devtools::install_cran('htmlTable')" && \
R -e "options(Ncpus = 4L); devtools::install_cran('knitr')" && \
R -e "options(Ncpus = 4L); devtools::install_cran('lubridate')" && \
R -e "options(Ncpus = 4L); devtools::install_cran('magrittr')" && \
R -e "options(Ncpus = 4L); devtools::install_cran('png')" && \
R -e "options(Ncpus = 4L); devtools::install_cran('qwraps2')" && \
R -e "options(Ncpus = 4L); devtools::install_cran('readr')" && \
R -e "options(Ncpus = 4L); devtools::install_cran('REDCapR')" && \
R -e "options(Ncpus = 4L); devtools::install_cran('reshape2')" && \
R -e "options(Ncpus = 4L); devtools::install_cran('scales')" && \
R -e "options(Ncpus = 4L); devtools::install_cran('sjPlot')" && \
R -e "options(Ncpus = 4L); devtools::install_cran('stringr')" && \
R -e "options(Ncpus = 4L); devtools::install_cran('tableone')" && \
R -e "options(Ncpus = 4L); devtools::install_cran('tidyr')" && \
R -e "options(Ncpus = 4L); devtools::install_cran('nycflights13')" && \
R -e "options(Ncpus = 4L); devtools::install_cran('data.table')" && \
R -e "options(Ncpus = 4L); devtools::install_cran('arrow')"
# Add a user with no password to the sudo group
RUN adduser --disabled-password --gecos '' ctd
USER ctd
WORKDIR /home/ctd
COPY . .
# run sample R script
RUN R CMD BATCH ./write-test.R
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment