from debian

#source for graph-tool
RUN echo "deb http://downloads.skewed.de/apt/stretch stretch main" >> /etc/apt/sources.list
RUN echo "deb-src http://downloads.skewed.de/apt/stretch stretch main" >> /etc/apt/sources.list

#install r,nano c++ lib and GRAPH-TOOL
RUN apt-get -y --allow-unauthenticated update
RUN apt-get -y install r-base r-base-dev && \
apt-get -y install nano && \
apt-get install -y libcurl4-openssl-dev libssl-dev libssh2-1-dev libxml2-dev 

RUN apt-get -y --allow-unauthenticated update
RUN apt-get -y --allow-unauthenticated install python-graph-tool

RUN apt-get -y install libudunits2-dev

#R

RUN apt-get install wget
RUN wget https://cloud.r-project.org/src/base/R-3/R-3.5.1.tar.gz
RUN gzip -dc R-3.5.1.tar.gz | tar -xf -
RUN cd R-3.5.1/ &&\
./configure --enable-R-shlib --with-x=no --with-tcltk=no && \
make && \
make check && \
make install && \
cd ..


#R library

RUN Rscript -e "install.packages('biocLite', repos='http://cran.r-project.org')"
RUN Rscript -e "install.packages('jsonlite', repos='http://cran.r-project.org')"
RUN Rscript -e "install.packages('data.table', repos='http://cran.r-project.org')"
RUN Rscript -e "install.packages('ggplot2', repos='http://cran.r-project.org')"
RUN Rscript -e "install.packages('grid', repos='http://cran.r-project.org')"
RUN Rscript -e "install.packages('reshape2', repos='http://cran.r-project.org')"
RUN Rscript -e "install.packages('RJSONIO', repos='http://cran.r-project.org')"
RUN Rscript -e "install.packages('stringr', repos='http://cran.r-project.org')"
RUN Rscript -e "install.packages('devtools', repos='http://cran.us.r-project.org')"

RUN Rscript -e "library(devtools)"
RUN Rscript -e 'source("http://bioconductor.org/biocLite.R")' -e 'biocLite("clusterProfiler")' -e 'biocLite("org.Hs.eg.db")'
RUN Rscript -e "install.packages('gplots', repos='http://cran.us.r-project.org')"


#adding scripts


RUN rm -rf /var/lib/apt/lists/*
RUN apt-get --allow-unauthenticated update
RUN apt-get -y install git
RUN Rscript -e "devtools::install_github(repo = 'loosolab/PARrOT/PARrOT',host = 'github.molgen.mpg.de/api/v3')"
RUN git clone "https://github.molgen.mpg.de/loosolab/PARrOT.git"

#adding directories

RUN mkdir INPUT
RUN mkdir OUTPUT

#change permission of the scripts
RUN chmod 700 ./PARrOT/scripts/*

ENTRYPOINT ["/bin/bash", "-c", "./PARrOT/scripts/containerrunner.sh"]