2016-04-13 15:38:30 +00:00
|
|
|
# Configuration file for Jupyter Hub
|
|
|
|
|
|
|
|
import os
|
|
|
|
import sys
|
2017-01-24 23:35:44 +00:00
|
|
|
import json
|
|
|
|
import grp
|
|
|
|
from os.path import join
|
2016-04-13 15:38:30 +00:00
|
|
|
|
|
|
|
c = get_config()
|
|
|
|
|
2017-01-24 23:35:44 +00:00
|
|
|
PREADMINS = set(os.environ.get('ADMINS', '').split(','))
|
|
|
|
OAUTH_CLASS = os.environ.get('OAUTH_CLASS', 'oauthenticator.GitHub')
|
|
|
|
HOME_FORMAT_STRING = os.environ.get('HOST_HOMEDIR', '/mnt/home/{username}')
|
|
|
|
here = os.path.dirname(__file__)
|
|
|
|
root = os.environ.get('OAUTHENTICATOR_DIR', here)
|
|
|
|
udir = os.environ.get('USERS_DIR', root)
|
|
|
|
sys.path.insert(0, root)
|
|
|
|
teams = os.environ.get('OAUTHENTICATOR_TEAMS', None)
|
|
|
|
|
2016-04-13 15:38:30 +00:00
|
|
|
c.JupyterHub.log_level = 10
|
2017-01-24 23:35:44 +00:00
|
|
|
c.JupyterHub.spawner_class = 'dockerspawner.DockerSpawner'
|
2017-08-30 11:55:07 +00:00
|
|
|
c.DockerSpawner.container_image = 'jupyter/scipy-notebook'
|
2016-04-13 15:38:30 +00:00
|
|
|
c.DockerSpawner.use_internal_ip = True
|
|
|
|
|
2017-01-24 23:35:44 +00:00
|
|
|
notebook_dir = os.environ.get('DOCKER_NOTEBOOK_DIR') or '/home/jovyan/work'
|
|
|
|
c.DockerSpawner.notebook_dir = notebook_dir
|
|
|
|
|
|
|
|
# Mount the real user's Docker volume on the host to the notebook user's
|
|
|
|
# notebook directory in the container
|
|
|
|
c.DockerSpawner.volumes = { HOME_FORMAT_STRING: notebook_dir }
|
2016-04-13 15:38:30 +00:00
|
|
|
|
2017-01-25 00:53:05 +00:00
|
|
|
common = os.environ.get('COMMON_DIR')
|
|
|
|
|
|
|
|
if common:
|
|
|
|
c.DockerSpawner.volumes[common] = join(notebook_dir, 'common')
|
|
|
|
|
|
|
|
dsdir = os.environ.get('DATASETS_DIR')
|
|
|
|
|
|
|
|
if dsdir:
|
|
|
|
c.DockerSpawner.read_only_volumes = { dsdir: join(notebook_dir, 'DATASETS')}
|
|
|
|
|
2016-04-13 15:38:30 +00:00
|
|
|
import socket
|
|
|
|
ips = ([ip for ip in socket.gethostbyname_ex(socket.gethostname())[2] if not ip.startswith("127.")][:1])
|
|
|
|
c.JupyterHub.hub_ip = ips[0]
|
|
|
|
|
2017-01-24 23:35:44 +00:00
|
|
|
# c.JupyterHub.authenticator_class = 'oauthenticator.{}'.format(auth_class_name)
|
|
|
|
c.JupyterHub.authenticator_class = OAUTH_CLASS
|
|
|
|
# auth_class = getattr(c, 'auth_class_name')
|
|
|
|
# auth_class = getattr(c, 'GitHubOAuthenticator')
|
|
|
|
# auth_class.oauth_callback_url = os.environ['OAUTH_CALLBACK_URL']
|
|
|
|
# auth_class = getattr(c, auth_short_name)
|
|
|
|
# auth_class.create_system_users = False
|
2016-04-13 15:38:30 +00:00
|
|
|
|
|
|
|
c.Authenticator.whitelist = whitelist = set()
|
2017-01-24 23:35:44 +00:00
|
|
|
c.Authenticator.admin_users = admin = PREADMINS
|
2016-04-13 15:38:30 +00:00
|
|
|
# ssl config
|
|
|
|
ssl = join(root, 'ssl')
|
|
|
|
keyfile = join(ssl, 'ssl.key')
|
|
|
|
certfile = join(ssl, 'ssl.cert')
|
|
|
|
if os.path.exists(keyfile):
|
|
|
|
c.JupyterHub.ssl_key = keyfile
|
|
|
|
if os.path.exists(certfile):
|
|
|
|
c.JupyterHub.ssl_cert = certfile
|
2017-01-24 23:35:44 +00:00
|
|
|
|
|
|
|
# load_from_json()
|