|
| 1 | +# Copyright (c) Jupyter Development Team. |
| 2 | +# Distributed under the terms of the Modified BSD License. |
| 3 | + |
| 4 | +# Configuration file for JupyterHub |
| 5 | +import os |
| 6 | + |
| 7 | +c = get_config() # noqa: F821 |
| 8 | + |
| 9 | +# We rely on environment variables to configure JupyterHub so that we |
| 10 | +# avoid having to rebuild the JupyterHub container every time we change a |
| 11 | +# configuration parameter. |
| 12 | + |
| 13 | +# Spawn single-user servers as Docker containers |
| 14 | +c.JupyterHub.spawner_class = "dockerspawner.DockerSpawner" |
| 15 | + |
| 16 | +# Spawn containers from this image |
| 17 | +c.DockerSpawner.image = os.environ["DOCKER_NOTEBOOK_IMAGE"] |
| 18 | + |
| 19 | +# Connect containers to this Docker network |
| 20 | +network_name = os.environ["DOCKER_NETWORK_NAME"] |
| 21 | +c.DockerSpawner.use_internal_ip = True |
| 22 | +c.DockerSpawner.network_name = network_name |
| 23 | + |
| 24 | +# Explicitly set notebook directory because we'll be mounting a volume to it. |
| 25 | +# Most `jupyter/docker-stacks` *-notebook images run the Notebook server as |
| 26 | +# user `jovyan`, and set the notebook directory to `/home/jovyan/work`. |
| 27 | +# We follow the same convention. |
| 28 | +notebook_dir = os.environ.get("DOCKER_NOTEBOOK_DIR", "/home/jovyan/work") |
| 29 | +c.DockerSpawner.notebook_dir = notebook_dir |
| 30 | + |
| 31 | +# Mount the real user's Docker volume on the host to the notebook user's |
| 32 | +# notebook directory in the container |
| 33 | +c.DockerSpawner.volumes = {"jupyterhub-user-{username}": notebook_dir} |
| 34 | + |
| 35 | +# Remove containers once they are stopped |
| 36 | +c.DockerSpawner.remove = True |
| 37 | + |
| 38 | +# For debugging arguments passed to spawned containers |
| 39 | +c.DockerSpawner.debug = True |
| 40 | + |
| 41 | +# User containers will access hub by container name on the Docker network |
| 42 | +c.JupyterHub.hub_ip = "jupyterhub" |
| 43 | +c.JupyterHub.hub_port = 8080 |
| 44 | + |
| 45 | +# Persist hub data on volume mounted inside container |
| 46 | +c.JupyterHub.cookie_secret_file = "/data/jupyterhub_cookie_secret" |
| 47 | +c.JupyterHub.db_url = "sqlite:////data/jupyterhub.sqlite" |
| 48 | + |
| 49 | +# Authenticate users with Native Authenticator |
| 50 | +c.JupyterHub.authenticator_class = "nativeauthenticator.NativeAuthenticator" |
| 51 | + |
| 52 | +# Allow anyone to sign-up without approval |
| 53 | +c.NativeAuthenticator.open_signup = True |
| 54 | + |
| 55 | +# Allowed admins |
| 56 | +admin = os.environ.get("JUPYTERHUB_ADMIN") |
| 57 | +if admin: |
| 58 | + c.Authenticator.admin_users = [admin] |
0 commit comments