Spaces:
Sleeping
Sleeping
############################# | |
# JUPYTER VOLUME DOCKERFILE # | |
#***************************# | |
# Set up a jupyter-lab for # | |
# developing using deepvats # | |
############################# | |
############## | |
# Base image # | |
############## | |
##--- Setup Ubuntu | |
ARG CUDA_VERSION | |
FROM nvidia/cuda:${CUDA_VERSION} | |
#--- Tags | |
LABEL maintainer="vrodriguezf <[email protected]>" | |
LABEL cuda_version=${CUDA_VERSION} | |
LABEL log_path=${log_path} | |
##---Initialize bash | |
LABEL cuda_version=${CUDA_VERSION} | |
RUN echo "Cuda version: $CUDA_VERSION" | |
##---Initialize bash | |
SHELL [ "/bin/bash", "--login", "-c" ] | |
################## | |
# Packages setup # | |
################## | |
#TODO: Automatizar que lo coja de /etc/timezone | |
#Only neccesary for libarchive & libtiff if error appears | |
ARG TZ=Etc/UTC | |
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone \ | |
&& apt-get update --fix-missing \ | |
#if errors with libtiff library | |
#&& apt-get install -y wget bzip2 curl git sudo libarchive-dev libtiff5-dev \ | |
&& apt-get install -y wget bzip2 curl git sudo libarchive-dev libtiff5-dev zsh\ | |
#Otherwise | |
# && apt-get install -y wget bzip2 curl git sudo \ | |
&& apt-get clean \ | |
&& rm -rf /var/lib/apt/lists/* | |
#-- Environmental variables for wandb | |
ENV LC_ALL=C.UTF-8 \ | |
LANG=C.UTF-8 | |
######################## | |
# Create non-root user # | |
######################## | |
ARG username=user\ | |
uid=1000 \ | |
gid=1000 | |
ENV USER=$username \ | |
UID=$uid \ | |
GID=$gid | |
ENV HOME=/home/$USER | |
#-- Passwordless sudo (TODO: mv to root section) | |
RUN addgroup --gid $GID $USER \ | |
&& adduser --disabled-password \ | |
--gecos "Non-root user" \ | |
--uid $UID \ | |
--gid $GID \ | |
--home $HOME $USER\ | |
&& echo "$USER ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers | |
#-- Move to user | |
USER $USER | |
# Add the jupyterlab settings | |
COPY --chown=$uid:$gid docker/jupyter_config $HOME/.jupyter | |
##################### | |
# Install miniconda # | |
##################### | |
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 --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 | |
##################################################### | |
# Install external libraries not available in conda # | |
##################################################### | |
RUN chmod u+x /usr/local/bin/postBuild \ | |
&& conda activate $ENV_PREFIX \ | |
&& pip install zennit==0.5.1 \ | |
&& conda deactivate | |
RUN conda list --prefix ${ENV_PREFIX} | |
COPY --chown=$UID:$GID docker/entrypoint.sh /usr/local/bin | |
RUN chmod u+x /usr/local/bin/entrypoint.sh | |
ENTRYPOINT [ "/usr/local/bin/entrypoint.sh" ] | |
ARG JUPYTER_TOKEN | |
ENV JUPYTER_TOKEN=${JUPYTER_TOKEN} | |
# default command will be to launch JupyterLab server for development | |
CMD ["sh", "-c", "jupyter lab --no-browser --ip 0.0.0.0 --ContentsManager.allow_hidden=True --NotebookApp.token=$JUPYTER_TOKEN"] |