FROM tomcat:9-jdk17-temurin-jammy 

RUN apt-get update && apt-get install -y sudo;

ARG RKEY=https://cloud.r-project.org/bin/linux/ubuntu/marutter_pubkey.asc 
ARG GPGKEY=/etc/apt/trusted.gpg.d/cran_ubuntu_key.asc 
RUN apt-get update && apt-get install -y \
		dirmngr \
        	gnupg \
		apt-transport-https \
		ca-certificates \
		software-properties-common \
	&& wget -qO- $RKEY | sudo tee -a $GPGKEY\
	&& add-apt-repository "deb https://cloud.r-project.org/bin/linux/ubuntu jammy-cran40/"\
	&& apt-get update --fix-missing\
	&& apt-get install -y r-base \
	&& apt-get install -y git \
	&& apt-get install -y libcurl4-openssl-dev libxml2-dev libssl-dev libfontconfig1-dev  libharfbuzz-dev libfribidi-dev libtiff5-dev git \
	&& rm -rf /var/lib/apt/lists/* 

#run this as root!
#RUN mkdir -p /home/labkey/R/site-library \
#   && export R_LIBS=/home/labkey/R/site-library \
#   && echo ${R_LIBS} \
RUN R -e 'install.packages("devtools")' \
   && R -e 'install.packages("ggplot2")' \
   && R -e 'install.packages("Rlabkey")' \
   && R -e 'install.packages("ggsurvfit")' \
   && R -e 'install.packages("ggalluvial")' \
   && R -e 'install.packages("gridExtra")' \
   && R -e 'install.packages("comprehenr")' \
   && R -e 'install.packages("ggsci")' \
   && R -e 'install.packages("paletteer")' \
   && R -e 'install.packages("tidyverse")'\
   && R -e 'install.packages("swimplot")'\
   && R -e 'install.packages("gtsummary")'
