# Dockerfile
FROM rocker/shiny:4.3.0

# Installer les dépendances système
RUN apt-get update && apt-get install -y \
    curl \
    build-essential \
    libssl-dev \
    libxml2-dev \
    libcurl4-openssl-dev \
    git \
    && rm -rf /var/lib/apt/lists/*

# Rust pour CLARABEL
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
ENV PATH="/root/.cargo/bin:${PATH}"

# Installer remotes et autres packages
RUN R -e "install.packages(c('remotes', 'shiny', 'shinythemes', 'shinyjs', 'DT', 'plotly', 'colourpicker', 'devtools'))"

# Installer CVXR et les solveurs
RUN R -e "install.packages(c('CVXR', 'osqp', 'ECOSolveR', 'scs', 'CLARABEL'))"

RUN R -e "install.packages('BsplineQuantReg', repos = 'https://cloud.r-project.org/')"

#RUN R -e "install.packages('BsplineQuantReg')"
RUN R -e " packageVersion('BsplineQuantReg') "
# Copier le package
#COPY . /tmp/BsplineQuantRegGui

# Installer le package avec verbose
RUN R -e "remotes::install_local('/tmp/BsplineQuantRegGui', force = TRUE, verbose = TRUE)"


RUN R -e "remotes::install_github('alexandreabbes/BsplineQuantRegGui')"

# Vérifier l'installation
RUN R -e "print(installed.packages()[,1])"

# Nettoyer
#RUN rm -rf /tmp/BsplineQuantRegGui
RUN R -e " packageVersion('BsplineQuantRegGui') "

# Exposer le port
EXPOSE 3838


#CMD ["R", "-e", "shiny::runApp('/inst/shiny', host='0.0.0.0', port=3838)"]

CMD ["R", "-e", "library(shiny); library(BsplineQuantRegGui); BsplineQuantRegGui::run_gui(host='0.0.0.0', port=3838)"]