|
12 | 12 |
|
13 | 13 | # Spawn single-user servers as Docker containers |
14 | 14 | c.JupyterHub.spawner_class = 'dockerspawner.DockerSpawner' |
| 15 | + |
15 | 16 | # Spawn containers from this image |
16 | | -c.DockerSpawner.container_image = os.environ['DOCKER_NOTEBOOK_IMAGE'] |
| 17 | +c.DockerSpawner.image = os.environ['DOCKER_NOTEBOOK_IMAGE'] |
| 18 | + |
17 | 19 | # JupyterHub requires a single-user instance of the Notebook server, so we |
18 | 20 | # default to using the `start-singleuser.sh` script included in the |
19 | 21 | # jupyter/docker-stacks *-notebook images as the Docker run command when |
20 | 22 | # spawning containers. Optionally, you can override the Docker run command |
21 | 23 | # using the DOCKER_SPAWN_CMD environment variable. |
22 | 24 | spawn_cmd = os.environ.get('DOCKER_SPAWN_CMD', "start-singleuser.sh") |
23 | | -c.DockerSpawner.extra_create_kwargs.update({ 'command': spawn_cmd }) |
| 25 | +c.DockerSpawner.cmd = spawn_cmd |
| 26 | + |
24 | 27 | # Connect containers to this Docker network |
25 | 28 | network_name = os.environ['DOCKER_NETWORK_NAME'] |
26 | 29 | c.DockerSpawner.use_internal_ip = True |
27 | 30 | c.DockerSpawner.network_name = network_name |
28 | | -# Pass the network name as argument to spawned containers |
29 | | -c.DockerSpawner.extra_host_config = { 'network_mode': network_name } |
30 | | -# Explicitly set notebook directory because we'll be mounting a host volume to |
31 | | -# it. Most jupyter/docker-stacks *-notebook images run the Notebook server as |
| 31 | + |
| 32 | +# Explicitly set notebook directory because we'll be mounting a volume to it. |
| 33 | +# Most jupyter/docker-stacks *-notebook images run the Notebook server as |
32 | 34 | # user `jovyan`, and set the notebook directory to `/home/jovyan/work`. |
33 | 35 | # We follow the same convention. |
34 | 36 | notebook_dir = os.environ.get('DOCKER_NOTEBOOK_DIR') or '/home/jovyan/work' |
35 | 37 | c.DockerSpawner.notebook_dir = notebook_dir |
| 38 | + |
36 | 39 | # Mount the real user's Docker volume on the host to the notebook user's |
37 | 40 | # notebook directory in the container |
38 | 41 | c.DockerSpawner.volumes = { 'jupyterhub-user-{username}': notebook_dir } |
39 | | -# volume_driver is no longer a keyword argument to create_container() |
40 | | -# c.DockerSpawner.extra_create_kwargs.update({ 'volume_driver': 'local' }) |
| 42 | + |
41 | 43 | # Remove containers once they are stopped |
42 | | -c.DockerSpawner.remove_containers = True |
| 44 | +c.DockerSpawner.remove = True |
| 45 | + |
43 | 46 | # For debugging arguments passed to spawned containers |
44 | 47 | c.DockerSpawner.debug = True |
45 | 48 |
|
46 | 49 | # User containers will access hub by container name on the Docker network |
47 | 50 | c.JupyterHub.hub_ip = 'jupyterhub' |
48 | 51 | c.JupyterHub.hub_port = 8080 |
49 | 52 |
|
50 | | -# TLS config |
51 | | -c.JupyterHub.port = 443 |
52 | | -c.JupyterHub.ssl_key = os.environ['SSL_KEY'] |
53 | | -c.JupyterHub.ssl_cert = os.environ['SSL_CERT'] |
54 | | - |
55 | | -# Authenticate users with GitHub OAuth |
56 | | -c.JupyterHub.authenticator_class = 'oauthenticator.GitHubOAuthenticator' |
57 | | -c.GitHubOAuthenticator.oauth_callback_url = os.environ['OAUTH_CALLBACK_URL'] |
58 | | - |
59 | 53 | # Persist hub data on volume mounted inside container |
60 | | -data_dir = os.environ.get('DATA_VOLUME_CONTAINER', '/data') |
61 | | - |
62 | | -c.JupyterHub.cookie_secret_file = os.path.join(data_dir, |
63 | | - 'jupyterhub_cookie_secret') |
| 54 | +c.JupyterHub.cookie_secret_file = '/data/jupyterhub_cookie_secret' |
| 55 | +c.JupyterHub.db_url = "sqlite:////data/jupyterhub.sqlite" |
64 | 56 |
|
65 | | -c.JupyterHub.db_url = 'postgresql://postgres:{password}@{host}/{db}'.format( |
66 | | - host=os.environ['POSTGRES_HOST'], |
67 | | - password=os.environ['POSTGRES_PASSWORD'], |
68 | | - db=os.environ['POSTGRES_DB'], |
69 | | -) |
| 57 | +# Authenticate users with Native Authenticator |
| 58 | +c.JupyterHub.authenticator_class = 'nativeauthenticator.NativeAuthenticator' |
70 | 59 |
|
71 | | -# Whitlelist users and admins |
72 | | -c.Authenticator.whitelist = whitelist = set() |
73 | | -c.Authenticator.admin_users = admin = set() |
74 | | -c.JupyterHub.admin_access = True |
75 | | -pwd = os.path.dirname(__file__) |
76 | | -with open(os.path.join(pwd, 'userlist')) as f: |
77 | | - for line in f: |
78 | | - if not line: |
79 | | - continue |
80 | | - parts = line.split() |
81 | | - # in case of newline at the end of userlist file |
82 | | - if len(parts) >= 1: |
83 | | - name = parts[0] |
84 | | - whitelist.add(name) |
85 | | - if len(parts) > 1 and parts[1] == 'admin': |
86 | | - admin.add(name) |
| 60 | +# Allowed admins |
| 61 | +admin = os.environ.get('JUPYTERHUB_ADMIN') |
| 62 | +if admin: |
| 63 | + c.Authenticator.admin_users = [admin] |
0 commit comments