From 5b055bbd1dee88da3a2a1ad0daf7fbc40bfdc5e3 Mon Sep 17 00:00:00 2001 From: mm Date: Fri, 24 Jun 2022 17:52:42 +0000 Subject: [PATCH] deployment updates --- .env | 4 ++-- Dockerfile.jupyterhub | 4 ++-- docker-compose.yml | 6 +++--- jupyterhub_config.py | 20 ++++++++++++-------- 4 files changed, 19 insertions(+), 15 deletions(-) diff --git a/.env b/.env index 292e607..fb483af 100755 --- a/.env +++ b/.env @@ -24,7 +24,7 @@ DOCKER_NETWORK_NAME=hub-network #DOCKER_NOTEBOOK_IMAGE=jupyter/tensorflow-notebook:4d9c9bd9ced0 # d0bfe4b38f78: tensorflow==2.4.1 python==3.9.2 lab==3.0.15 notebook==6.3.0 hub==1.4.1 # 23ac04200f8f: tensorflow==2.6.0 python==3.9.7 lab==3.2.3 notebook==6.4.5 hub==1.5.0 -DOCKER_NOTEBOOK_IMAGE=jupyter/tensorflow-notebook:hub-1.5.0 +DOCKER_NOTEBOOK_IMAGE=jupyter/scipy-notebook:hub-1.5.0 # the local image we use, after pinning jupyterhub version #LOCAL_NOTEBOOK_IMAGE=jupyterhub-user @@ -44,6 +44,6 @@ DOCKER_SPAWN_CMD=start-singleuser.sh # afterwards, you can visit /hub/login_list (if enabled and you are an admin) to see everyone's passwords. # by default, hub-admin will be an admin user (defined in jupyterhub_config.py). # you can print the password for this hub-admin user with 'bash show_login.sh' -USERNAME=`whoami` +USERNAME=mm PASSWORD_LENGTH=6 HUB_LOC=`pwd` diff --git a/Dockerfile.jupyterhub b/Dockerfile.jupyterhub index 6e4ff42..50893b6 100755 --- a/Dockerfile.jupyterhub +++ b/Dockerfile.jupyterhub @@ -6,7 +6,7 @@ FROM jupyterhub/jupyterhub-onbuild:$JUPYTERHUB_VERSION # Install dockerspawner, oauth, postgres RUN pip install psycopg2-binary~=2.7 && \ pip install --no-cache-dir \ - oauthenticator==0.8.* + oauthenticator~=14.2.0 RUN pip install jupyterhub-hashauthenticator dockerspawner~=12.0 RUN pip install jupyterhub-idle-culler @@ -19,4 +19,4 @@ RUN pip install jupyterhub-idle-culler #RUN chmod 700 /srv/jupyterhub/secrets && \ # chmod 600 /srv/jupyterhub/secrets/* -#COPY ./userlist /srv/jupyterhub/userlist \ No newline at end of file +#COPY ./userlist /srv/jupyterhub/userlist diff --git a/docker-compose.yml b/docker-compose.yml index 868c1d2..19401a4 100755 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,7 +6,7 @@ version: "3" services: hub-db: - image: postgres:9.5 + image: postgres:14.1 container_name: ${HUB_NAME}-db restart: always environment: @@ -37,8 +37,8 @@ services: - ./jupyterhub_config.py:/srv/jupyterhub/jupyterhub_config.py - ./userlist:/srv/jupyterhub/userlist # - "/tmp/.X11-unix:/tmp/.X11-unix" - ports: - - "${PORT_NUM}:8000" + # ports: + # - "${PORT_NUM}:8000" links: - hub-db environment: diff --git a/jupyterhub_config.py b/jupyterhub_config.py index 2aa6bf4..a461f1f 100755 --- a/jupyterhub_config.py +++ b/jupyterhub_config.py @@ -118,10 +118,11 @@ class MyDockerSpawner(DockerSpawner): self.default_url = '/lab' def update_volumes(self, group_list): - for group_id in group_list: - mode = 'rw' if 'admin' in group_list else 'ro' - volume = create_volume_mount(group_id, mode, 'jovyan') - self.volumes.update(volume) + mode = 'rw' if 'admin' in group_list else 'ro' + for group_id in group_list: # do not want "shared-admin" folder. + if group_id != 'admin': + volume = create_volume_mount(group_id, mode, 'jovyan') + self.volumes.update(volume) def limit_resources(self, mem_limit='8G', cpu_limit=1.0): self.mem_limit = mem_limit @@ -184,12 +185,13 @@ c.DockerSpawner.debug = True # User containers will access hub by container name on the Docker network c.JupyterHub.hub_ip = HUB_NAME # The hub will be hosted at example.com/HUB_NAME/ -c.JupyterHub.base_url = u'/%s/'%HUB_NAME +#c.JupyterHub.base_url = u'/%s/'%HUB_NAME +c.JupyterHub.base_url = u'/' #c.JupyterHub.hub_port = 8001 ## Authentication # Whitlelist users and admins -c.Authenticator.allowed_users = whitelist = set() +c.Authenticator.allowed_users = allowed_users = set() c.Authenticator.admin_users = admin = set() # add default user so that first-time log in is easy. @@ -197,12 +199,14 @@ admin.add('hub-admin') for name in GROUP_MAP: if 'admin' in GROUP_MAP[name]: admin.add(name) - else: - whitelist.add(name) + allowed_users.add(name) # Authenticate users with GitHub OAuth c.JupyterHub.authenticator_class = 'oauthenticator.GitHubOAuthenticator' c.GitHubOAuthenticator.oauth_callback_url = os.environ['OAUTH_CALLBACK_URL'] +#c.GitHubOAuthenticator.allowed_organizations = {'ml-starter-packs', 'mindthemath', 'mindthegrow'} +#c.GitHubOAuthenticator.scope = ['read:org', 'user:email'] + # Authenticate with thedataincubator/jupyterhub-hashauthenticator ##c.JupyterHub.authenticator_class = 'hashauthenticator.HashAuthenticator'