Spaces:
Sleeping
Sleeping
File size: 4,790 Bytes
f58f618 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 |
#############################
# 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"] |