diff --git a/.env b/.env index 3f40f68b17..5b1e3a0ec7 100644 --- a/.env +++ b/.env @@ -1,3 +1,5 @@ DOCKER_STOCHSS_IMAGE=stochss-lab DOCKER_BASE_IMAGE=jupyter/minimal-notebook:latest + +JUPYTER_CONFIG_DIR=/opt/stochss-config/.jupyter diff --git a/Dockerfile b/Dockerfile index 91c63d5450..147aa4d72d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,7 @@ FROM jupyter/minimal-notebook:latest ARG STOCHSS_PIP_EDITABLE +ARG JUPYTER_CONFIG_DIR USER root @@ -20,11 +21,11 @@ COPY --chown=jovyan:users public_models/ /home/jovyan/Examples COPY --chown=jovyan:users . /stochss -COPY --chown=jovyan:users stochss-logo.png /home/jovyan/.jupyter/custom/logo.png +COPY --chown=jovyan:users stochss-logo.png $JUPYTER_CONFIG_DIR/custom/logo.png -COPY --chown=jovyan:users custom.css /home/jovyan/.jupyter/custom/custom.css +COPY --chown=jovyan:users custom.css $JUPYTER_CONFIG_DIR/custom/custom.css -COPY --chown=jovyan:users jupyter_notebook_config.py /home/jovyan/.jupyter/jupyter_notebook_config.py +COPY --chown=jovyan:users jupyter_notebook_config.py $JUPYTER_CONFIG_DIR/jupyter_notebook_config.py RUN pip install --no-cache-dir -e . diff --git a/Makefile b/Makefile index 35a04ec43a..927b9f8190 100644 --- a/Makefile +++ b/Makefile @@ -100,11 +100,14 @@ clean_notebook_server: hub: build_hub build run_hub_dev build_clean: deps webpack - docker build --no-cache -t $(DOCKER_STOCHSS_IMAGE):latest . + docker build \ + --build-arg JUPYTER_CONFIG_DIR=$(JUPYTER_CONFIG_DIR) \ + --no-cache -t $(DOCKER_STOCHSS_IMAGE):latest . build: deps webpack docker build \ - -t $(DOCKER_STOCHSS_IMAGE):latest . + --build-arg JUPYTER_CONFIG_DIR=$(JUPYTER_CONFIG_DIR) \ + -t $(DOCKER_STOCHSS_IMAGE):latest . test: build docker run --rm \ diff --git a/jupyterhub/.env b/jupyterhub/.env index 3a6bf796fe..fc16435bd1 100644 --- a/jupyterhub/.env +++ b/jupyterhub/.env @@ -3,6 +3,8 @@ DOCKER_STOCHSS_IMAGE=stochss-lab POWER_USERS_FILE=.power_users +JUPYTER_CONFIG_DIR=/opt/stochss-config/.jupyter + #AUTH_CLASS=jupyterhub.auth.DummyAuthenticator JUPYTERHUB_VERSION=1.1.0 diff --git a/jupyterhub/jupyterhub_config.py b/jupyterhub/jupyterhub_config.py index 6939f03cf9..6b4103d270 100644 --- a/jupyterhub/jupyterhub_config.py +++ b/jupyterhub/jupyterhub_config.py @@ -131,7 +131,7 @@ # Dockerspawner configuration #------------------------------------------------------------------------------ -c.DockerSpawner.container_image = os.environ['DOCKER_STOCHSS_IMAGE'] +c.DockerSpawner.image = os.environ['DOCKER_STOCHSS_IMAGE'] # JupyterHub requires a single-user instance of the Notebook server, so we # default to using the `start-singleuser.sh` script included in the # jupyter/docker-stacks *-notebook images as the Docker run command when @@ -157,7 +157,10 @@ # Mount the real user's Docker volume on the host to the notebook user's # notebook directory in the container c.DockerSpawner.volumes = { 'jupyterhub-user-{username}': notebook_dir } - +# Set extra environment variables +c.DockerSpawner.environment = { + 'JUPYTER_CONFIG_DIR': os.environ['JUPYTER_CONFIG_DIR'] +} # Remove containers once they are stopped c.DockerSpawner.remove_containers = True # For debugging arguments passed to spawned containers