
# Base image
FROM ubuntu:16.04
MAINTAINER Paul Murrell <paul@stat.auckland.ac.nz>

# add CRAN PPA
RUN apt-get update && apt-get install -y apt-transport-https
RUN echo 'deb https://cloud.r-project.org/bin/linux/ubuntu xenial/' > /etc/apt/sources.list.d/cran.list
RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E084DAB9

# Install additional software
# R stuff
RUN apt-get update && apt-get install -y \
    xsltproc \
    r-base=3.3.2* \ 
    libxml2-dev \
    libcurl4-openssl-dev \
    libssl-dev \
    subversion 

# Audio/video/desktop stuff
RUN apt-get update && apt-get install -y \
    espeak \
    wmctrl \
    sysvinit-utils \
    xdotool \
    ffmpeg \
    ffmpeg2theora

# Set up keyboard so do not get prompted during build
COPY ./keyboard /etc/default/keyboard
# Set up Xvfb so docker run can work off-screen
RUN apt-get update && apt-get install -y \
    xvfb \
    metacity 
ENV DISPLAY :1
# Ambiance theme for metacity
RUN apt-get install -y light-themes

# Examples in report
RUN apt-get update && apt-get install -y \
    libcanberra-gtk3-module \
    gnome-terminal \
    firefox
# Needed for gnome-terminal to work
RUN locale-gen en_US.UTF-8
ENV LANG en_US.UTF-8

# Screen shots in report
RUN apt-get update && apt-get install -y \
    gnome-screenshot

RUN Rscript -e 'install.packages(c("knitr", "devtools"), repos="https://cran.rstudio.com/")'
RUN Rscript -e 'library(devtools); install_version("xml2", "1.0.0", repos="https://cran.rstudio.com/")'
RUN Rscript -e 'library(devtools); install_version("tuneR", "1.3.1", repos="https://cran.rstudio.com/")'

RUN Rscript -e 'library(devtools); install_github("pmur002/wmctrl@v0.1-2")'
RUN Rscript -e 'library(devtools); install_github("pmur002/xdotool@v0.1")'
RUN Rscript -e 'library(devtools); install_github("pmur002/ffmpeg@v0.1-1")'
RUN Rscript -e 'library(devtools); install_github("pmur002/director@v0.1")'

RUN Rscript -e 'library(devtools); install_version("XML", "3.98-1.4", repos="https://cran.rstudio.com/")'
RUN Rscript -e 'library(devtools); install_version("gridSVG", "1.5-0", repos="https://cran.rstudio.com/")'
RUN Rscript -e 'library(devtools); install_github("pmur002/DOM@v0.4")'
