jupyterhub config hash

This commit is contained in:
M. Pilosov 2019-01-03 02:05:58 -07:00
parent 37f78caac4
commit 88ba451f37

View File

@ -13,8 +13,9 @@ c = get_config()
# Spawn single-user servers as Docker containers
c.JupyterHub.spawner_class = 'dockerspawner.DockerSpawner'
# Spawn containers from this image
# c.DockerSpawner.container_image = os.environ['DOCKER_NOTEBOOK_IMAGE']
c.DockerSpawner.container_image = "jupyter/scipy-notebook"
c.DockerSpawner.container_image = os.environ['DOCKER_NOTEBOOK_IMAGE']
# c.DockerSpawner.container_image = "jupyter/scipy-notebook"
# JupyterHub requires a single-user instance of the Notebook server, so we
# default to using the `start-singleuser.sh` script included in the
# jupyter/docker-stacks *-notebook images as the Docker run command when
@ -22,12 +23,17 @@ c.DockerSpawner.container_image = "jupyter/scipy-notebook"
# using the DOCKER_SPAWN_CMD environment variable.
spawn_cmd = os.environ.get('DOCKER_SPAWN_CMD', "start-singleuser.sh")
c.DockerSpawner.extra_create_kwargs.update({ 'command': spawn_cmd })
# Memory limit
c.Spawner.mem_limit = '1G'
# Connect containers to this Docker network
network_name = os.environ['DOCKER_NETWORK_NAME']
c.DockerSpawner.use_internal_ip = True
c.DockerSpawner.network_name = network_name
# Pass the network name as argument to spawned containers
c.DockerSpawner.extra_host_config = { 'network_mode': network_name }
# Explicitly set notebook directory because we'll be mounting a host volume to
# it. Most jupyter/docker-stacks *-notebook images run the Notebook server as
# user `jovyan`, and set the notebook directory to `/home/jovyan/work`.
@ -38,8 +44,8 @@ c.DockerSpawner.notebook_dir = notebook_dir
# notebook directory in the container
# c.DockerSpawner.volumes = { 'jupyterhub-user-{username}': notebook_dir }
c.DockerSpawner.volumes = { 'jupyterhub-user-{username}': notebook_dir,
'/home/michael/repos/':'/home/jovyan/work/shared/' }
c.DockerSpawner.volumes = { 'power-user-{username}': notebook_dir,
'/home/michael/repos/':'/home/shared/' }
# volume_driver is no longer a keyword argument to create_container()
# c.DockerSpawner.extra_create_kwargs.update({ 'volume_driver': 'local' })
@ -57,10 +63,23 @@ c.JupyterHub.hub_ip = 'jupyterhub'
#c.JupyterHub.ssl_key = os.environ['SSL_KEY']
#c.JupyterHub.ssl_cert = os.environ['SSL_CERT']
### Authentication
# Authenticate users with GitHub OAuth
c.JupyterHub.authenticator_class = 'oauthenticator.GitHubOAuthenticator'
c.GitHubOAuthenticator.oauth_callback_url = os.environ['OAUTH_CALLBACK_URL']
# c.JupyterHub.authenticator_class = 'oauthenticator.GitHubOAuthenticator'
# c.GitHubOAuthenticator.oauth_callback_url = os.environ['OAUTH_CALLBACK_URL']
# Authenticate with thedataincubator/jupyterhub-hashauthenticator
c.JupyterHub.authenticator_class = 'hashauthenticator.HashAuthenticator'
# You can generate a good "secret key" by running `openssl rand -hex 32` in terminal.
# it is recommended to do this from time-to-time to change passwords (including changing their length)
c.HashAuthenticator.secret_key = '20a507952405b2e398542c721ce4954c1514ac079c0373e70a517595a43a9013' # Defaults to ''
c.HashAuthenticator.password_length = 5 # Defaults to 6
# If the `show_logins` option is set to `True`, a CSV file containing
#login names and passwords will be served (to admins only) at `/hub/login_list`.
c.HashAuthenticator.show_logins = True # Optional, defaults to False
### Database Interaction - cookies, db for jupyterhub
# Persist hub data on volume mounted inside container
data_dir = os.environ.get('DATA_VOLUME_CONTAINER', '/data')
@ -89,3 +108,12 @@ with open(os.path.join(pwd, 'userlist')) as f:
whitelist.add(name)
if len(parts) > 1 and parts[1] == 'admin':
admin.add(name)
# Run script to automatically stop idle single-user servers as a jupyterhub service.
c.JupyterHub.services = [
{
'name': 'cull_idle',
'admin': True,
'command': 'python /srv/jupyterhub/cull_idle_servers.py --timeout=3600'.split(),
},
]