 # jupyterhub_config.py
c = get_config()

import my_oauthenticator

import os
pjoin = os.path.join

runtime_dir = os.path.join('/srv/jupyterhub')
ssl_dir = pjoin(runtime_dir, 'ssl')
if not os.path.exists(ssl_dir):
    os.makedirs(ssl_dir)

c.JupyterHub.port = 8000
c.JupyterHub.ssl_key = pjoin(ssl_dir, 'hub.key')
c.JupyterHub.ssl_cert = pjoin(ssl_dir, 'hub.crt')

c.JupyterHub.cookie_secret_file = pjoin(runtime_dir, 'cookie_secret')
c.JupyterHub.db_url = pjoin(runtime_dir, 'jupyterhub.sqlite')


# use GoogleOAuthenticator + LocalAuthenticator
c.JupyterHub.authenticator_class = my_oauthenticator.LocalGoogleOAuthenticator

c.GoogleOAuthenticator.client_id = os.environ['OAUTH_CLIENT_ID']
c.GoogleOAuthenticator.client_secret = os.environ['OAUTH_CLIENT_SECRET']
c.GoogleOAuthenticator.oauth_callback_url = os.environ['OAUTH_CALLBACK_URL']


# create system users that don't exist yet
c.Authenticator.create_system_users = False
# Default adduser flags are for FreeBSD (works on CentOS 5, Debian, Ubuntu)
# Doesn't work for us.
# https://github.com/jupyterhub/jupyterhub/issues/696
#c.Authenticator.add_user_cmd =  ['adduser', '--home', '/home/USERNAME']
#c.Authenticator.add_user_cmd =  ['adduser', '--home', '/mnt/nfs/home/USERNAME'] # not yet

c.Authenticator.whitelist = whitelist = set()
c.Authenticator.admin_users = admin = set()

with open(pjoin(runtime_dir, '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)




# nginx config stuff
# Force the proxy to only listen to connections to 127.0.0.1
c.JupyterHub.ip = '127.0.0.1'
#c.JupyterHub.ip = '0.0.0.0'
c.JupyterHub.proxy_api_ip = '127.0.0.1'


# Zonca + legacy swarm
# Point DockerSpawner to Swarm instead of the local DockerEngine
os.environ["DOCKER_HOST"] = ":4000"

c.JupyterHub.spawner_class = 'dockerspawner.SystemUserSpawner'
c.DockerSpawner.container_image = 'data8-notebook'

## Remove containers once they are stopped
c.Spawner.remove_containers = True
#
## For debugging arguments passed to spawned containers
c.Spawner.debug = True



#notebook_dir = '/home/{username}'
#c.DockerSpawner.notebook_dir = notebook_dir
c.DockerSpawner.notebook_dir = '/'
#c.DockerSpawner.notebook_dir = '/mnt/nfs/home'


# The docker instances need access to the Hub, so the default loopback port doesn't work:
from jupyter_client.localinterfaces import public_ips
c.JupyterHub.hub_ip = public_ips()[0]
#print('hub_ip = ',c.JupyterHub.hub_ip)


# The docker instances need access to the Hub, so the default loopback port
# doesn't work. We need to tell the hub to listen on 0.0.0.0 because it's in a
# container, and we'll expose the port properly when the container is run. Then,
# we explicitly tell the spawned containers to connect to the proper IP address.
#c.JupyterHub.proxy_api_ip = '0.0.0.0'
c.DockerSpawner.container_ip = '0.0.0.0'
c.DockerSpawner.use_internal_ip = False

c.DockerSpawner.hub_ip_connect = c.JupyterHub.hub_ip




# Mount the real user's Docker volume on the host to the notebook user's
# notebook directory in the container
#c.DockerSpawner.volumes = { 'jupyterhub-user-{username}': notebook_dir }
#c.DockerSpawner.volumes = { '/mnt/nfs/home': notebook_dir }
c.DockerSpawner.volumes = { '/mnt/nfs/home': '/home' }
#c.DockerSpawner.volumes = { '/mnt/nfs/home': {'bind': '/home', 'mode': 'rw'}}
#c.DockerSpawner.volumes = { '/home': '/mnt/nfs/home'}
#c.DockerSpawner.extra_create_kwargs.update({ 'volume_driver': 'local' })

c.SystemUserSpawner.host_homedir_format_string = '/mnt/nfs/home/{username}'
#c.SystemUserSpawner.host_homedir_format_string = '/mnt/nfs/home' # so they can see all users files (e.g., for sharing)
#c.SystemUserSpawner.image_homedir_format_string = '/home'




@@ -2111,11 +2111,9 @@
 rue%0A
-#%0A#
+%0A
 # Fo
@@ -2306,52 +2306,8 @@
 = '/
-'%0A#c.DockerSpawner.notebook_dir = '/mnt/nfs/
 home
@@ -3143,406 +3143,87 @@
 iner
-%0A#c.DockerSpawner.volumes = %7B 'jupyterhub-user-%7Busername%7D': notebook_dir %7D%0A#c.DockerSpawner.volumes = %7B '/mnt/nfs/home': notebook_dir %7D%0Ac.DockerSpawner.volumes = %7B '/mnt/nfs/home': '/home' %7D%0A#c.DockerSpawner.volumes = %7B '/mnt/nfs/home': %7B'bind': '/home', 'mode': 'rw'%7D%7D%0A#c.DockerSpawner.volumes = %7B '/home': '/mnt/nfs/home'%7D%0A#c.DockerSpawner.extra_create_kwargs.update(%7B 'volume_driver': 'local' %7D)
+.  Mount all of NFS home%0Ac.DockerSpawner.volumes = %7B '/mnt/nfs/home': '/home' %7D
 %0A%0Ac.
@@ -3296,27 +3296,23 @@
 rname%7D'%0A
-#c.SystemUs
+%0Ac.Dock
 erSpawne
@@ -3317,165 +3317,45 @@
 ner.
-host_homedir_format_string = '/mnt/nfs/home' # so they can see all users files (e.g., for sharing)%0A#c.SystemUserSpawner.image_homedir_format_string = '/home'%0A%0A
+extra_host_config = %7B'mem_limit': '1g'%7D
 %0A%0A

Clean up config.py