FROM rocker/r-ver

RUN apt-get update \
  && apt-get install -y --no-install-recommends \
     pandoc \
     pandoc-citeproc \
     libcurl4-gnutls-dev \
     libcairo2-dev \
     libxt-dev \
     xtail \
     libssl-dev \
     libicu-dev \
     wget



# Create a directory for your Shiny app
RUN mkdir -p /srv/shiny 

RUN apt-get update

RUN apt-get install -y cmake

RUN apt-get install -y libssl-dev

RUN apt-get install -y libharfbuzz-dev 

RUN apt-get install -y libfribidi-dev

RUN apt-get install -y libxml2-dev

RUN apt-get install -y libexpat1

RUN apt-get install -y libfontconfig1-dev




# Expose the port Shiny app runs on
EXPOSE 8080

# Command to run the Shiny app
RUN R -e "install.packages('nloptr',dependencies=TRUE,repos='http://cran.rstudio.com')"
RUN R -e "install.packages('emmeans',dependencies=TRUE,repos='http://cran.rstudio.com')"
RUN R -e "install.packages('officer',dependencies=TRUE,repos='http://cran.rstudio.com')"
RUN R -e "install.packages(c('dplyr', 'shiny', 'readxl', 'remotes', 'httpuv', 'shinythemes', 'DT', 'ggplot2', 'gridExtra', 'emmeans'), repos = 'http://cran.rstudio.com/', method='wget',dependencies=TRUE)"
RUN R -e "install.packages(c('officer','car','pls', 'markdown', 'plotly', 'factoextra', 'shinylogs', 'auth0', 'httr', 'shinyjs','urltools','openssl'), repos = 'http://cran.rstudio.com/', method='wget',dependencies=TRUE)"
RUN R -e "install.packages('shinyBS',repos = 'http://cran.rstudio.com/', method='wget',dependencies=TRUE)"
# Copy the Shiny app to the container
COPY README.md /srv/shiny/README.md
COPY arbre1.png /srv/shiny/arbre1.png
COPY arbre2.png /srv/shiny/arbre2.png
COPY .Renviron /srv/shiny/.Renviron
COPY app.R /srv/shiny/app.R
COPY ./modules /srv/shiny/modules
COPY server.R /srv/shiny/server.R
COPY ui.R /srv/shiny/ui.R
COPY install_packages.R /srv/shiny/install_packages.R

#RUN Rscript /srv/shiny/install_packages.R

CMD ["R", "-e", "shiny::runApp('/srv/shiny', host='0.0.0.0', port=8080, launch.browser = FALSE)"]
