-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathjupyterhub_config.py
More file actions
61 lines (51 loc) · 2.28 KB
/
Copy pathjupyterhub_config.py
File metadata and controls
61 lines (51 loc) · 2.28 KB
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
import os
c = get_config()
c.JupyterHub.debug_proxy = True
# Spawn a docker container per user
c.JupyterHub.spawner_class = 'dockerspawner.DockerSpawner'
c.DockerSpawner.use_internal_ip = True
c.DockerSpawner.debug = True
c.DockerSpawner.remove_containers = True
# Spawn user containers from this image
c.DockerSpawner.container_image = 'jupyter'
c.DockerSpawner.notebook_dir = '/home/jovyan/work'
c.DockerSpawner.volumes={'/data/notebooks/{username}': '/home/jovyan/work',
'/data': '/data',
'/var/run/docker.sock': '/var/run/docker.sock'}
# c.DockerSpawner.read_only_volumes = {'/data/notebooks/': '/home/jovyan/work/readonly'}
c.DockerSpawner.extra_create_kwargs.update({'volume_driver': 'local'})
# Connect containers to this Docker network
network_name = os.environ['COMPOSE_PROJECT_NAME'] + '_default'
c.DockerSpawner.network_name = network_name
c.DockerSpawner.extra_host_config.update({'network_mode': network_name})
# User containers will access hub by container name on the Docker network
c.DockerSpawner.container_ip = "0.0.0.0"
c.JupyterHub.hub_ip = 'jupyterhub'
c.JupyterHub.hub_port = 8080
c.JupyterHub.port = 8000
# Have the Spawner override the Docker run command
c.DockerSpawner.extra_create_kwargs.update({
'command': '/usr/local/bin/start-singleuser.sh'
})
# Persist hub data on volume mounted inside container
c.JupyterHub.db_url = 'sqlite:////data/jupyterhub/jupyterhub.sqlite'
c.JupyterHub.cookie_secret_file = '/data/jupyterhub/jupyterhub_cookie_secret'
# Authenticate users with GitHub OAuth
c.JupyterHub.authenticator_class = 'oauthenticator.GitHubOAuthenticator'
c.GitHubOAuthenticator.client_id = os.environ['GITHUB_CLIENT_ID']
c.GitHubOAuthenticator.client_secret = os.environ['GITHUB_CLIENT_SECRET']
c.GitHubOAuthenticator.oauth_callback_url = os.environ['OAUTH_CALLBACK_URL']
# Whitlelist users and admins
c.Authenticator.whitelist = whitelist = set()
c.Authenticator.admin_users = admin = set()
c.JupyterHub.admin_access = True
pwd = os.path.dirname(__file__)
with open(os.path.join(pwd, '/data/jupyterhub/userlist')) as f:
for line in f:
if not line:
continue
parts = line.split()
name = parts[0]
whitelist.add(name)
if len(parts) > 1 and parts[1] == 'admin':
admin.add(name)