FROM ubuntu:bionic

# need to update so gnupg1 can be found
RUN apt update
RUN apt install -y gnupg1 software-properties-common

# the tzdata package asks for the timezone interactively when it is updated,
# but we don't have an interactive terminal during the build process
# these environment variables and commands avoid the manual configuration
# https://serverfault.com/questions/683605/docker-container-time-timezone-will-not-reflect-changes
ENV TZ=America/New_York
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

#  install R from the r-project repo
RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9
RUN add-apt-repository 'deb https://cloud.r-project.org/bin/linux/ubuntu bionic-cran35/'
RUN apt install -y r-base

# drop into an R interpreter on run
CMD ["R","--vanilla"]
