-
Notifications
You must be signed in to change notification settings - Fork 61
/
jupyterhub_config.py-docker
45 lines (38 loc) · 1.45 KB
/
jupyterhub_config.py-docker
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
"""
jupyterhub_config.py-docker
---------------------------
Configuration for JupyterHub tutorial - used for docker deployment
"""
# SSL and hub port
c.JupyterHub.ssl_key = 'jupyterhub.key'
c.JupyterHub.ssl_cert = 'jupyterhub.crt'
# or letsencrypt:
# c.JupyterHub.ssl_key = '/etc/letsencrypt/live/hub-tutorial.jupyter.org/privkey.pem'
# c.JupyterHub.ssl_cert = '/etc/letsencrypt/live/hub-tutorial.jupyter.org/fullchain.pem'
# c.JupyterHub.port = 443
# User whitelist - set of users allowed to use the Hub
c.Authenticator.whitelist = {'minrk', 'willingc', 'yuvipanda'}
# Administrators - set of users who can administer the Hub itself
c.Authenticator.admin_users = {'minrk'}
# Authenticator
from oauthenticator.github import GitHubOAuthenticator
c.JupyterHub.authenticator_class = GitHubOAuthenticator
# Spawner
from dockerspawner import DockerSpawner
c.JupyterHub.spawner_class = DockerSpawner
# Hub IP and port
#
# By default, the Hub's API listens on localhost.
# Yet, a docker container can't see the Hub's localhost.
# Set the Hub's IP address to the docker0 address and
# tell the Hub to listen on its docker network.
# netifaces is a convenience library to gather IP information.
import netifaces
import platform
if platform.system() == 'Darwin':
en0 = netifaces.ifaddresses('en0')
docker_ipv4 = en0[netifaces.AF_INET][0]
else:
docker0 = netifaces.ifaddresses('docker0')
docker_ipv4 = docker0[netifaces.AF_INET][0]
c.JupyterHub.hub_ip = docker_ipv4['addr']