#R-Shiny template https://huggingface.co/spaces/posit/shiny-for-r-template/tree/main #Py-shiny template https://huggingface.co/spaces/posit/gptneox-chat ############################# # RSTUDIO-SERVER # # VOLUME DOCKERFILE # #***************************# # Set up a jupyter-lab for # # developing using deepvats # ############################# ############## # Base image # ############## # Adds rstudio server, tiyverse, devtools to rocker/cuda FROM dvats-rstudio-base:latest SHELL [ "/bin/bash", "--login", "-c" ] ############### # Ensure vars # (Only for local test - DON'T USE IT IN HUGGINGFACE. ENSURE .env IS NOT ACCESIBLE IN THE WEB, USE THEIR SECRET MANAGEMENT) ############### RUN echo "--> ARGS" ARG USER_NAME \ USER_ID \ GROUP_ID \ WANDB_API_KEY \ WANDB_ENTITY \ WANDB_PROJECT \ GH_TOKEN RUN echo "--> ARGS -> ENV" ENV USER_NAME=$USER_NAME \ USER_ID=$USER_ID \ GROUP_ID=$GROUP_ID \ WANDB_ENTITY=$WANDB_ENTITY \ WANDB_API_KEY=$WANDB_API_KEY \ GH_TOKEN=$ghtoken \ WANDB_PROJECT=$WANDB_PROJECT RUN echo "--> Setup ENV variables" ENV RETICULATE_PYTHON_ENV=/home/${USER_NAME}/env \ ROOT=TRUE \ RETICULATE_MINICONDA_PATH=/home/${USER_NAME}/miniconda \ CUDA_VISIBLE_DEVICES=0,1,2 \ ENV_VARS=WANDB_ENTITY,WANDB_PROJECT,USER_NAME,USER_ID,GROUP_ID,PASSWORD,ROOT,CUDA_VISIBLE_DEVICES\ HOME="/home/${USER_NAME}" ########### # Volumes # ########### RUN echo "---> Setup volumes" \ echo ${HOME} \ echo ${USER_NAME}"|"${USER_ID}"|"${GROUP_ID} COPY --chown=${USER_ID}:${GROUP_ID} ../r_shiny_app $HOME/app COPY --chown=${USER_ID}:${GROUP_ID} ${LOCAL_DATA_PATH} $HOME/data/ COPY --chown=${USER_ID}:${GROUP_ID} ../dvats ${HOME}/dvats RUN echo "--> Prior installations" \ apt-key adv --keyserver keyserver.ubuntu.com --recv-keys A4B469963BF863CC \ set -e; \ apt-get update --fix-missing \ && apt-get install -y \ python3-pip wget bzip2 curl \ git sudo libarchive-dev libtiff5-dev zsh\ #python3 -m pip install --upgrade pip \ python3-venv libxt-dev \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* ## Install R packages #COPY docker/DESCRIPTION /tmp/ COPY --chown=${USER_ID}:${GROUP_ID} docker/DESCRIPTION /tmp/ RUN ls -la /tmp/ && sleep 5 RUN echo "--> Install R packages" #RUN R -e "install.packages(deps_path = '/tmp/DESCRIPTION', remotes::dev_package_deps(dependencies = TRUE), repos = NULL)" RUN R -e "devtools::install_deps('/tmp/', dependencies = TRUE)" #RUN R -e "install.packages(c('shiny', 'pals', 'shinyWidgets', 'dygraphs', 'shinycssloaders', 'shinyjs', 'Rcpp', 'reactlog', 'pals', 'feather', 'fasttime', 'zoo', 'shinyWidgets'))" #RUN R -e "remotes::install_github('r-lib/later')" #RUN R -e "remotes::install_github('apache/arrow/r')" ## Install reticulate and create virtual environment using default Ubuntu installed Python #RUN R -e "install.packages('reticulate')" ENV ENV_PREFIX $HOME/env RUN echo "---> Make sudo & setup sudoers" RUN echo "$(id)" ARG RETICULATE_MINICONDA_PATH=/usr/local/share/r-miniconda ARG RETICULATE_PYTHON_ENV=/usr/virtualenvs/venv_shiny_app ENV RETICULATE_PYTHON=${RETICULATE_PYTHON_ENV}/bin/python/ RUN echo "---> RETICULATE PYTHONS" RUN echo "RETICULATE_PYTHON_ENV=${RETICULATE_PYTHON_ENV}" >> ${HOME}/.Renviron RUN echo "RETICULATE_PYTHON=${RETICULATE_PYTHON}" >> ${HOME}/.Renviron RUN echo "---> Export W&B" ## Export W&B environment variable to Rstudio ARG WANDB_API_KEY RUN echo "WANDB_API_KEY=${WANDB_API_KEY}" >> ${HOME}/.Renviron ENV MINICONDA_VERSION=4.10.3 \ #ENV MINICONDA_VERSION=23.9.0 \ CONDA_DIR=$HOME/miniconda3 \ # Make non-activate conda commands available PATH=$CONDA_DIR/bin:$PATH \ PROJECT_DIR=$HOME RUN echo "HOME: ${HOME} | CONDA_DIR = ${CONDA_DIR}" \ #-- Install MINICONDA && wget --quiet https://repo.anaconda.com/miniconda/Miniconda3-py38_$MINICONDA_VERSION-Linux-x86_64.sh -O ~/miniconda.sh \ && chmod +x ~/miniconda.sh \ && ~/miniconda.sh -b -p $CONDA_DIR \ && rm ~/miniconda.sh # Make conda activate command available from /bin/bash --login shells RUN echo ". $CONDA_DIR/etc/profile.d/conda.sh" >> ~/.profile # make conda activate command available from /bin/bash --interative shells RUN conda init bash \ # create a project directory inside user home && mkdir -p $PROJECT_DIR WORKDIR $PROJECT_DIR ########################## # Install & update MAMBA # ########################## ENV ENV_PREFIX $PROJECT_DIR/env RUN conda install --name base --channel conda-forge mamba \ && mamba update --name base --channel defaults conda #-- Build the mamba environment RUN mamba install conda-lock -c conda-forge COPY --chown=$UID:$GID docker/environment.yml docker/requirements.txt /tmp/ #RUN mamba lock -f /tmp/environment.yml --lockfile /tmp/environment.lock #RUN mamba create --prefix ${ENV_PREFIX} --file /tmp/environment.lock RUN mamba env create -vv --prefix ${ENV_PREFIX} --file /tmp/environment.yml RUN conda clean --all --yes # run the postBuild script to install the JupyterLab extensions COPY --chown=$UID:$GID docker/postBuild /usr/local/bin RUN chmod u+x /usr/local/bin/postBuild \ && conda activate $ENV_PREFIX \ && /usr/local/bin/postBuild \ && conda deactivate \ # Make bash automatically activate the conda environment && echo "conda activate $ENV_PREFIX" >> ~/.bashrc RUN chmod u+x /usr/local/bin/postBuild \ && conda activate $ENV_PREFIX \ && /usr/local/bin/postBuild \ && conda deactivate \ # Make bash automatically activate the conda environment && echo "conda activate $ENV_PREFIX" >> ~/.bashrc RUN conda list --prefix ${ENV_PREFIX} RUN echo "--> rewrrite miniconda path" # Rewrite the miniconda path environment in case it has been redefined in the compose file RUN echo "RETICULATE_MINICONDA_PATH=${RETICULATE_MINICONDA_PATH}" >> ${HOME}/.Renviron RUN echo "---> Make non-activate conda commands available" RUN # make non-activate conda commands available ENV PATH=${RETICULATE_MINICONDA_PATH}/bin:${PATH} RUN echo "--> Permissions" RUN echo "$(id )" #RUN echo "--> Setup miniconda & Mamba" #RUN echo ". ${HOME}miniconda3/etc/profile.d/conda.sh" >> ${HOME}/rstudio/.bashrc #RUN echo "--> Conda activate" # Make bash automatically activate the conda environment #RUN echo "conda activate ${ENV_PREFIX}" >> ${HOME}/rstudio/.bashrc #echo "export WANDB_ENTITY=${WANDB_ENTITY:-default}" >> ${HOME}/.bashrc # echo "WANDB_ENTITY=${WANDB_ENTITY:-default}" >> ${HOME}/.Renviron # Define an array of environment variable names from the ENV_VARS Compose variable ARG ENV_VARS=ENV_VARS RUN echo "---> Setup variables" && \ IFS=',' read -ra NAMES <<< "ENV_VARS" && \ for ENV_VAR_NAsME in "${NAMES[@]}"; do \ #echo "$ENV_VARS" | tr ',' '\n' | while read ENV_VAR_NAME; do \ ENV_VAR_VALUE="${!ENV_VAR_NAME:-default}"; \ echo "$ENV_VAR_NAME=$ENV_VAR_VALUE"; \ done > ${HOME}/.Renviron RUN echo "--> Go!" CMD ["R", "--quiet", "-e", "shiny::runApp(host='0.0.0.0', port=${RSTUDIO_PORT:-3838}, launch.browser = FALSE, appDir = '/home/${USER_NAME}/app')"] # CMD ["/init"]