diff --git a/terra-base-jupyter/Dockerfile b/terra-base-jupyter/Dockerfile index 6370d526..4900a091 100644 --- a/terra-base-jupyter/Dockerfile +++ b/terra-base-jupyter/Dockerfile @@ -77,6 +77,7 @@ RUN useradd -m -N -u $WELDER_UID $WELDER_USER # Create the jupyter user ENV JUPYTER_USER jupyter-user ENV JUPYTER_UID 1002 +# Create the jupyter user home ENV JUPYTER_USER_HOME /home/$JUPYTER_USER RUN useradd -m -d $JUPYTER_USER_HOME -N -u $JUPYTER_UID -g users $JUPYTER_USER # We want to grant the jupyter user sudo permissions @@ -98,9 +99,6 @@ ENV CONDA_ENV_HOME $JUPYTER_USER_HOME/.envs/$CONDA_ENV_NAME RUN curl -so $JUPYTER_USER_HOME/miniconda.sh ${CONDA_INSTALLER} \ && chmod +x $JUPYTER_USER_HOME/miniconda.sh \ && $JUPYTER_USER_HOME/miniconda.sh -b -p $CONDA_ENV_HOME \ - # Make sure the USER is the owner of the folder where - # the base python is installed, and subsequent conda environments - && chown -R $USER:users $JUPYTER_USER_HOME \ && rm $JUPYTER_USER_HOME/miniconda.sh ENV PATH "${PATH}:${CONDA_ENV_HOME}/bin" @@ -120,8 +118,10 @@ COPY conda-environment.yml . RUN conda env update --prefix $CONDA_ENV_HOME --file conda-environment.yml --prune \ # Remove packages tarballs and python bytecode files from the image && conda clean -afy \ - # && find $CONDA_ENV_HOME -follow -type f -name '*.pyc' -delete \ - && rm conda-environment.yml + && rm conda-environment.yml \ + # Make sure the JUPYTER_USER is the owner of the folder where + # the base conda is installed + && chown -R $JUPYTER_USER:users $JUPYTER_USER_HOME # Add the user base conda environment as a jupyter kernel - this should be the default now # This commands activates the conda environment and then calls ipykernel from within @@ -187,9 +187,9 @@ RUN $JUPYTER_HOME/bin/jupyter kernelspec remove python3 -y COPY run-jupyter.sh $JUPYTER_HOME/run-jupyter.sh RUN chmod +x $JUPYTER_HOME/run-jupyter.sh -# Set up the user and working directory +# Set up the user and working directory, which is where the persistent disk will be mounted USER $JUPYTER_USER -WORKDIR $JUPYTER_USER_HOME +WORKDIR $JUPYTER_USER_HOME/persistent_disk # Note: this entrypoint is provided for running Jupyter independently of Leonardo. # When Leonardo deploys this image onto a cluster, the entrypoint is overwritten to enable diff --git a/terra-base-jupyter/run-jupyter.sh b/terra-base-jupyter/run-jupyter.sh index 8c117c32..f0259314 100644 --- a/terra-base-jupyter/run-jupyter.sh +++ b/terra-base-jupyter/run-jupyter.sh @@ -5,13 +5,12 @@ set -e # Change the default umask to support R/W access to the shared volume with welder umask 002 -# TODO: change default to ${HOME}/notebooks once welder is rolled out to all clusters SERVER_APP_BASE_URL=${1:-${HOME}} SERVER_APP_WEBSOCKET_URL=${2:-${HOME}} NOTEBOOKS_DIR=${3:-${HOME}} JUPYTER_BASE="/usr/jupytervenv/bin/python /usr/jupytervenv/bin/jupyter server" -JUPYTER_CMD="$JUPYTER_BASE --ServerApp.base_url=${SERVER_APP_BASE_URL} --ServerApp.websocket_url=${SERVER_APP_WEBSOCKET_URL} --autoreload&> ${NOTEBOOKS_DIR}/jupyter.log" +JUPYTER_CMD="$JUPYTER_BASE --ServerApp.base_url=${SERVER_APP_BASE_URL} --ServerApp.websocket_url=${SERVER_APP_WEBSOCKET_URL} --ServerApp.root_dir=${NOTEBOOKS_DIR} --autoreload&> ${NOTEBOOKS_DIR}/jupyter.log" echo $JUPYTER_CMD