# Install shiny R
FROM rocker/shiny:4.0.2

# Install Python3 and Git
RUN apt-get update \
  && apt-get install -y --no-install-recommends \
    software-properties-common \
    bash-completion \
    python3-pip \
    git \
    glpk-utils

# Let's see if we can get away with the onboard Python
# Add Python 3.7 repository
#RUN add-apt-repository ppa:deadsnakes/ppa

# Install Python 3.7
#RUN apt-get update \
#  && apt-get install -y --no-install-recommends \
#    python3.7 \
#    python3.7-dev \
#    python3.7-distutils

# Install Dev
RUN apt-get update \
  && apt-get install -y --no-install-recommends \
    python3-dev \
    python3-distutils

# Add Python3 as default in REnviron (forces me to pick version)
RUN echo "RETICULATE_PYTHON='/usr/bin/python3'" >> /usr/local/lib/R/etc/Renviron

#  install pydfs_lineup_optimizer and cplex
# from my own repository.
RUN python3 -m pip install git+https://github.com/anthonyshook/pydfs-lineup-optimizer.git
# add this @pydfs-3.3

# Install CPLEX (not currently working)
RUN python3 -m pip install cplex

# Add Python to path
ENV PATH "$PATH:/usr/bin/python3"

# Install necessary R packages
COPY ./requirements-r.txt /requirements-r.txt
RUN Rscript -e 'install.packages(readLines("requirements-r.txt"))'

# Copy Application Data Across to the server
COPY ./shiny_app/ /srv/shiny-server/optimizer/
