From 5e48f8e4311f5ff3b7a61d8e5d4a9f075945935f Mon Sep 17 00:00:00 2001 From: mathematicalmichael Date: Wed, 30 Jan 2019 09:58:22 -0700 Subject: [PATCH 01/18] MPI added. --- singleuser/Dockerfile | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/singleuser/Dockerfile b/singleuser/Dockerfile index 49b436b..1ad2418 100755 --- a/singleuser/Dockerfile +++ b/singleuser/Dockerfile @@ -1,7 +1,9 @@ ARG DOCKER_NOTEBOOK_IMAGE +ARG DISPLAY FROM $DOCKER_NOTEBOOK_IMAGE ARG JUPYTERHUB_VERSION #any additional installations go here. +RUN export DISPLAY=$DISPLAY USER root @@ -12,19 +14,22 @@ RUN apt-get update && \ fonts-dejavu \ tzdata \ gfortran \ - gcc && \ - rm -rf /var/lib/apt/lists/* + gcc +# finish off with MPI dependencies +RUN sudo apt-get install mpich libmpich-dev && \ + rm -rf /var/lib/apt/lists/* USER jovyan RUN python3 -m pip install --no-cache jupyterhub==$JUPYTERHUB_VERSION nbresuse RUN conda install -c conda-forge fenics -RUN python3 -m pip install ipyparallel +RUN python3 -m pip install ipyparallel mpi4py RUN ipython profile create --parallel --profile=mpi RUN echo "c.IPClusterEngines.engine_launcher_class = 'MPIEngineSetLauncher'" >> /home/jovyan/.ipython/profile_mpi/ipcluster_config.py -RUN conda create --quiet --yes -p $CONDA_DIR/envs/python2 python=2.7 ipython ipykernel kernda numpy pandas matplotlib ipywidgets yaml +RUN conda create --quiet --yes -p $CONDA_DIR/envs/python2 python=2.7 ipython ipykernel kernda numpy pandas matplotlib ipywidgets yaml ipyparallel mpi4py +RUN /opt/conda/envs/python2/bin/ipython profile create --parallel --profile=mpi USER root @@ -65,4 +70,3 @@ ENV LD_LIBRARY_PATH="/usr/lib/R/lib:/lib:/usr/lib/jvm/java-7-openjdk-amd64/jre/l USER jovyan RUN echo "export EDITOR=/usr/bin/vim" >> /home/jovyan/.bashrc -RUN echo "source /home/jovyan/work/.bash_custom" >> /home/jovyan/.bashrc From 3c7807035991687d3df9dc471f39702222045fd2 Mon Sep 17 00:00:00 2001 From: mathematicalmichael Date: Fri, 15 Feb 2019 10:04:06 -0700 Subject: [PATCH 02/18] changes to default config. --- .env | 1 + Dockerfile.jupyterhub | 6 ++++++ jupyterhub_config.py | 4 +++- setup.sh | 1 + 4 files changed, 11 insertions(+), 1 deletion(-) diff --git a/.env b/.env index 58784ec..d974f28 100755 --- a/.env +++ b/.env @@ -41,3 +41,4 @@ DOCKER_SPAWN_CMD=start-singleuser.sh # you can print the password for this hub-admin user with 'bash show_login.sh' USERNAME=hub-admin PASSWORD_LENGTH=6 +HUB_LOC=/home/pilosovm/hub diff --git a/Dockerfile.jupyterhub b/Dockerfile.jupyterhub index d88b9cd..672ab9e 100755 --- a/Dockerfile.jupyterhub +++ b/Dockerfile.jupyterhub @@ -8,6 +8,12 @@ RUN /opt/conda/bin/conda install -yq psycopg2=2.7 && \ /opt/conda/bin/conda clean -tipsy && \ /opt/conda/bin/pip install --no-cache-dir \ oauthenticator==0.8.* +RUN apt-get update && \ + apt-get install -y --no-install-recommends \ + vim + +RUN apt-get clean && \ + rm -rf /var/lib/apt/lists/* RUN pip install jupyterhub-hashauthenticator git+https://github.com/jupyterhub/dockerspawner.git@master diff --git a/jupyterhub_config.py b/jupyterhub_config.py index 8244e5c..8f4ee9e 100755 --- a/jupyterhub_config.py +++ b/jupyterhub_config.py @@ -44,7 +44,9 @@ class MyDockerSpawner(DockerSpawner): 'mode': 'rw', # or ro for read-only } if self.user.name == 'hub-admin': # if admin, allow userlist access - self.volumes[os.path.join(pwd,'userlist')] = { 'bind': '/home/jovyan/userlist', + self.volumes['%s/userlist'%(os.environ['HUB_LOC'])] = { 'bind': '/home/jovyan/userlist', + 'mode': 'rw' } + self.volumes['%s/jupyterhub_config.py'%(os.environ['HUB_LOC'])] = { 'bind': '/home/jovyan/jupyterhub_config.py', 'mode': 'rw' } return super().start() diff --git a/setup.sh b/setup.sh index 892b3a4..88efffb 100755 --- a/setup.sh +++ b/setup.sh @@ -7,6 +7,7 @@ echo "hub-admin admin shared" > userlist mkdir secrets make secrets/oauth.env make secrets/postgres.env +echo "HUB_LOC=$(pwd)" >> .env source .env # show what is needed to be added to /etc/nginx/sites-enabled/hub.conf From a01578197a467d33c30b853f2a71286374685a45 Mon Sep 17 00:00:00 2001 From: mathematicalmichael Date: Fri, 15 Feb 2019 12:21:15 -0700 Subject: [PATCH 03/18] updated configs. --- jupyterhub_config.py | 2 +- singleuser/Dockerfile | 12 +++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/jupyterhub_config.py b/jupyterhub_config.py index 8f4ee9e..cba288f 100755 --- a/jupyterhub_config.py +++ b/jupyterhub_config.py @@ -76,7 +76,7 @@ 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 = '2G' # RAM limit +c.Spawner.mem_limit = '50G' # RAM limit c.Spawner.cpu_limit = 0.0001 # Connect containers to this Docker network diff --git a/singleuser/Dockerfile b/singleuser/Dockerfile index 1ad2418..5ae993c 100755 --- a/singleuser/Dockerfile +++ b/singleuser/Dockerfile @@ -13,16 +13,18 @@ RUN apt-get update && \ htop \ fonts-dejavu \ tzdata \ - gfortran \ - gcc + gfortran + +RUN apt-get install -y gcc + # finish off with MPI dependencies -RUN sudo apt-get install mpich libmpich-dev && \ - rm -rf /var/lib/apt/lists/* +RUN sudo apt-get install mpich libmpich-dev -y && \ + rm -rf /var/lib/apt/lists/* USER jovyan RUN python3 -m pip install --no-cache jupyterhub==$JUPYTERHUB_VERSION nbresuse -RUN conda install -c conda-forge fenics +#RUN conda install -c conda-forge fenics RUN python3 -m pip install ipyparallel mpi4py RUN ipython profile create --parallel --profile=mpi From ae9513d7a908c51fb38974849b2b423c3243a6c2 Mon Sep 17 00:00:00 2001 From: mathematicalmichael Date: Fri, 15 Feb 2019 20:41:47 -0700 Subject: [PATCH 04/18] small tweaks. --- jupyterhub_config.py | 16 +++++++++++----- makefile | 2 +- singleuser/Dockerfile | 12 +++++------- 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/jupyterhub_config.py b/jupyterhub_config.py index cba288f..678b1c5 100755 --- a/jupyterhub_config.py +++ b/jupyterhub_config.py @@ -38,11 +38,17 @@ class MyDockerSpawner(DockerSpawner): if self.user.name in self.group_map: group_list = self.group_map[self.user.name] # add team volume to volumes - for group_id in group_list: - self.volumes['shared-{}'.format(group_id)] = { - 'bind': '/home/jovyan/%s'%(group_id), - 'mode': 'rw', # or ro for read-only - } + for group_id in group_list: # one superuser gets upload rights. + if self.user.name == 'hub-admin': + self.volumes['shared-{}'.format(group_id)] = { + 'bind': '/home/jovyan/%s'%(group_id), + 'mode': 'rw', # or ro for read-only + } + else: # this "shared-" is part of the naming convention + self.volumes['shared-{}'.format(group_id)] = { + 'bind': '/home/jovyan/%s'%(group_id), + 'mode': 'ro', + } if self.user.name == 'hub-admin': # if admin, allow userlist access self.volumes['%s/userlist'%(os.environ['HUB_LOC'])] = { 'bind': '/home/jovyan/userlist', 'mode': 'rw' } diff --git a/makefile b/makefile index 1c9149c..2b2536a 100755 --- a/makefile +++ b/makefile @@ -17,7 +17,7 @@ secrets/postgres.env: @echo "POSTGRES_PASSWORD=$(shell openssl rand -hex 32)" > $@ secrets/oauth.env: - @echo "Generating postgres password in $@" + @echo "Generating hash key in $@" @echo "HASH_SECRET_KEY=$(shell openssl rand -hex 32)" > $@ login: diff --git a/singleuser/Dockerfile b/singleuser/Dockerfile index 5ae993c..64ce801 100755 --- a/singleuser/Dockerfile +++ b/singleuser/Dockerfile @@ -13,27 +13,25 @@ RUN apt-get update && \ htop \ fonts-dejavu \ tzdata \ - gfortran - -RUN apt-get install -y gcc + gfortran \ + gcc # finish off with MPI dependencies -RUN sudo apt-get install mpich libmpich-dev -y && \ - rm -rf /var/lib/apt/lists/* +RUN sudo apt-get install mpich libmpich-dev -y && rm -rf /var/lib/apt/lists/* +RUN conda update --all && conda install fenics USER jovyan RUN python3 -m pip install --no-cache jupyterhub==$JUPYTERHUB_VERSION nbresuse -#RUN conda install -c conda-forge fenics RUN python3 -m pip install ipyparallel mpi4py RUN ipython profile create --parallel --profile=mpi RUN echo "c.IPClusterEngines.engine_launcher_class = 'MPIEngineSetLauncher'" >> /home/jovyan/.ipython/profile_mpi/ipcluster_config.py +USER root RUN conda create --quiet --yes -p $CONDA_DIR/envs/python2 python=2.7 ipython ipykernel kernda numpy pandas matplotlib ipywidgets yaml ipyparallel mpi4py RUN /opt/conda/envs/python2/bin/ipython profile create --parallel --profile=mpi -USER root # Create a global kernelspec in the image and modify it so that it properly activates # the python2 conda environment. From 4a7a37693e8fcf8ea5cd3c21af4bc43ccee412bd Mon Sep 17 00:00:00 2001 From: mathematicalmichael Date: Fri, 15 Feb 2019 20:50:00 -0700 Subject: [PATCH 05/18] fixes path --- .env | 1 - jupyterhub_config.py | 3 ++- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.env b/.env index d974f28..58784ec 100755 --- a/.env +++ b/.env @@ -41,4 +41,3 @@ DOCKER_SPAWN_CMD=start-singleuser.sh # you can print the password for this hub-admin user with 'bash show_login.sh' USERNAME=hub-admin PASSWORD_LENGTH=6 -HUB_LOC=/home/pilosovm/hub diff --git a/jupyterhub_config.py b/jupyterhub_config.py index 678b1c5..1fa2e8a 100755 --- a/jupyterhub_config.py +++ b/jupyterhub_config.py @@ -1,5 +1,6 @@ # Copyright (c) Jupyter Development Team. # Distributed under the terms of the Modified BSD License. +# Major edits by MathematicalMichael(.com) 02-2019 # Configuration file for JupyterHub import os @@ -82,7 +83,7 @@ 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 = '50G' # RAM limit +c.Spawner.mem_limit = '4G' # RAM limit c.Spawner.cpu_limit = 0.0001 # Connect containers to this Docker network From b28c4bd989c266bc44240007735734e9df8d91c6 Mon Sep 17 00:00:00 2001 From: mathematicalmichael Date: Mon, 18 Feb 2019 13:43:44 -0700 Subject: [PATCH 06/18] upgrade features for groups. --- groups.sh | 8 ++++++++ setup.sh | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100755 groups.sh diff --git a/groups.sh b/groups.sh new file mode 100755 index 0000000..1a1f07d --- /dev/null +++ b/groups.sh @@ -0,0 +1,8 @@ +#!/bin/bash +source .env +NUM_GROUPS=4 +for i in `seq 1 $NUM_GROUPS`; do + docker volume create shared-$HUB_NAME-group$i + sudo chmod 777 $(docker inspect shared-$HUB_NAME-group$i | grep "Mountpoint" | awk '{print $2}' | sed 's/"//g' | sed 's/,//g') +done + diff --git a/setup.sh b/setup.sh index 88efffb..1cdca33 100755 --- a/setup.sh +++ b/setup.sh @@ -20,7 +20,7 @@ docker-compose up -d echo -en "\n\nWe create a default shared volume and set its permissions to be read/write. You may have to enter your password now:\n" docker volume create shared-shared sudo chmod 777 $(docker inspect shared-shared | grep "Mountpoint" | awk '{print $2}' | sed 's/"//g' | sed 's/,//g') -echo -en "Volume has been created." +echo -en "Globally shared volume has been created." echo -en "\n\nHub has been launched. Here are the Docker processes running right now:" docker ps --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}" From 178bcc2534cd21e06132c7aa8cb9889e47ac2afd Mon Sep 17 00:00:00 2001 From: mathematicalmichael Date: Mon, 18 Feb 2019 13:45:44 -0700 Subject: [PATCH 07/18] instructions. --- setup.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/setup.sh b/setup.sh index 1cdca33..257ddb8 100755 --- a/setup.sh +++ b/setup.sh @@ -3,7 +3,8 @@ # this script is meant to be run only the first time a hub is being set up. # create a default userlist -echo "hub-admin admin shared" > userlist +echo "Use the format \"studentname HUB_NAME-group1\" on each line to add students to groups (10 by default have already been created and permissions appropriately set)" > userlist +echo "hub-admin admin shared" >> userlist mkdir secrets make secrets/oauth.env make secrets/postgres.env From 7db31543dd3b5544ce964778883584f618bc3ba5 Mon Sep 17 00:00:00 2001 From: mathematicalmichael Date: Mon, 18 Feb 2019 13:52:07 -0700 Subject: [PATCH 08/18] comments and updates to notebook image. --- singleuser/Dockerfile | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/singleuser/Dockerfile b/singleuser/Dockerfile index 64ce801..9d83749 100755 --- a/singleuser/Dockerfile +++ b/singleuser/Dockerfile @@ -16,28 +16,35 @@ RUN apt-get update && \ gfortran \ gcc -# finish off with MPI dependencies -RUN sudo apt-get install mpich libmpich-dev -y && rm -rf /var/lib/apt/lists/* +# finish off with MPI dependencies (only required if not installing fenics) +#RUN sudo apt-get install mpich libmpich-dev -y && rm -rf /var/lib/apt/lists/* -RUN conda update --all && conda install fenics USER jovyan +RUN conda update --all +RUN conda install fenics -RUN python3 -m pip install --no-cache jupyterhub==$JUPYTERHUB_VERSION nbresuse +RUN python3 -m pip install --no-cache jupyterhub==$JUPYTERHUB_VERSION nbresuse && \ + jupyter labextension install jupyterlab-topbar-extension && \ + jupyter labextension install jupyterlab-system-monitor +# If you do not need parallelism, delete the following. RUN python3 -m pip install ipyparallel mpi4py RUN ipython profile create --parallel --profile=mpi +RUN ipython profile create --parallel --profile=default RUN echo "c.IPClusterEngines.engine_launcher_class = 'MPIEngineSetLauncher'" >> /home/jovyan/.ipython/profile_mpi/ipcluster_config.py +# Python 2 environment USER root RUN conda create --quiet --yes -p $CONDA_DIR/envs/python2 python=2.7 ipython ipykernel kernda numpy pandas matplotlib ipywidgets yaml ipyparallel mpi4py RUN /opt/conda/envs/python2/bin/ipython profile create --parallel --profile=mpi - # Create a global kernelspec in the image and modify it so that it properly activates # the python2 conda environment. RUN $CONDA_DIR/envs/python2/bin/python -m ipykernel install && \ $CONDA_DIR/envs/python2/bin/kernda -o -y /usr/local/share/jupyter/kernels/python2/kernel.json + +# R environment USER root RUN apt-get update && \ @@ -68,5 +75,7 @@ ENV PATH="${PATH}:/usr/lib/rstudio-server/bin" ENV LD_LIBRARY_PATH="/usr/lib/R/lib:/lib:/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/amd64/server:/opt/conda/lib/R/lib" #ENV LD_LIBRARY_PATH="/usr/lib/R/lib:/lib:/usr/lib/x86_64-linux-gnu:/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/amd64/server:/opt/conda/lib/R/lib" + +# USER SETTINGS USER jovyan RUN echo "export EDITOR=/usr/bin/vim" >> /home/jovyan/.bashrc From f81046c8769651f072454e1066c80fb38cfd74ba Mon Sep 17 00:00:00 2001 From: mathematicalmichael Date: Mon, 18 Feb 2019 14:00:01 -0700 Subject: [PATCH 09/18] clean list during build. --- singleuser/Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/singleuser/Dockerfile b/singleuser/Dockerfile index 9d83749..0e17675 100755 --- a/singleuser/Dockerfile +++ b/singleuser/Dockerfile @@ -17,7 +17,8 @@ RUN apt-get update && \ gcc # finish off with MPI dependencies (only required if not installing fenics) -#RUN sudo apt-get install mpich libmpich-dev -y && rm -rf /var/lib/apt/lists/* +#RUN sudo apt-get install mpich libmpich-dev -y +RUN rm -rf /var/lib/apt/lists/* USER jovyan RUN conda update --all From 5ca00bd9b6d935b6f0083baee2bdea13b298c5bf Mon Sep 17 00:00:00 2001 From: mathematicalmichael Date: Mon, 18 Feb 2019 17:22:33 -0700 Subject: [PATCH 10/18] permissions fixed. --- singleuser/Dockerfile | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/singleuser/Dockerfile b/singleuser/Dockerfile index 0e17675..2210804 100755 --- a/singleuser/Dockerfile +++ b/singleuser/Dockerfile @@ -24,10 +24,6 @@ USER jovyan RUN conda update --all RUN conda install fenics -RUN python3 -m pip install --no-cache jupyterhub==$JUPYTERHUB_VERSION nbresuse && \ - jupyter labextension install jupyterlab-topbar-extension && \ - jupyter labextension install jupyterlab-system-monitor - # If you do not need parallelism, delete the following. RUN python3 -m pip install ipyparallel mpi4py RUN ipython profile create --parallel --profile=mpi @@ -35,15 +31,26 @@ RUN ipython profile create --parallel --profile=default RUN echo "c.IPClusterEngines.engine_launcher_class = 'MPIEngineSetLauncher'" >> /home/jovyan/.ipython/profile_mpi/ipcluster_config.py # Python 2 environment -USER root -RUN conda create --quiet --yes -p $CONDA_DIR/envs/python2 python=2.7 ipython ipykernel kernda numpy pandas matplotlib ipywidgets yaml ipyparallel mpi4py +RUN conda create --quiet --yes -p $CONDA_DIR/envs/python2 python=2.7 ipython ipykernel kernda numpy pandas matplotlib ipywidgets yaml ipyparallel mpi4py scipy pyDOE RUN /opt/conda/envs/python2/bin/ipython profile create --parallel --profile=mpi +USER root # Create a global kernelspec in the image and modify it so that it properly activates # the python2 conda environment. RUN $CONDA_DIR/envs/python2/bin/python -m ipykernel install && \ $CONDA_DIR/envs/python2/bin/kernda -o -y /usr/local/share/jupyter/kernels/python2/kernel.json +USER $NB_UID +# Jupyterhub and memory monitoring +RUN python3 -m pip install --no-cache jupyterhub==$JUPYTERHUB_VERSION nbresuse && \ + jupyter labextension install jupyterlab-topbar-extension && \ + jupyter labextension install jupyterlab-system-monitor && \ + npm cache clean --force && \ + rm -rf $CONDA_DIR/share/jupyter/lab/staging && \ + rm -rf /home/$NB_USER/.cache/yarn && \ + rm -rf /home/$NB_USER/.node-gyp && \ + fix-permissions $CONDA_DIR && \ + fix-permissions /home/$NB_USER # R environment USER root From b82f309d24661e78eff0d592c96d7f94e8d74519 Mon Sep 17 00:00:00 2001 From: mathematicalmichael Date: Mon, 18 Feb 2019 21:17:22 -0700 Subject: [PATCH 11/18] admin structure. --- jupyterhub_config.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/jupyterhub_config.py b/jupyterhub_config.py index 1fa2e8a..4df61f7 100755 --- a/jupyterhub_config.py +++ b/jupyterhub_config.py @@ -33,23 +33,23 @@ class MyDockerSpawner(DockerSpawner): for i in range(1,len(parts)): group_id = parts.pop() - if group_id != 'admin': # no need for an admin group. - group_map[user_name].append(group_id) + group_map[user_name].append(group_id) def start(self): if self.user.name in self.group_map: group_list = self.group_map[self.user.name] # add team volume to volumes for group_id in group_list: # one superuser gets upload rights. - if self.user.name == 'hub-admin': - self.volumes['shared-{}'.format(group_id)] = { - 'bind': '/home/jovyan/%s'%(group_id), - 'mode': 'rw', # or ro for read-only - } - else: # this "shared-" is part of the naming convention - self.volumes['shared-{}'.format(group_id)] = { - 'bind': '/home/jovyan/%s'%(group_id), - 'mode': 'ro', - } + if group_id != 'admin': + if 'admin' in group_list: + self.volumes['shared-{}'.format(group_id)] = { + 'bind': '/home/jovyan/%s'%(group_id), + 'mode': 'rw', # or ro for read-only + } + else: # this "shared-" is part of the naming convention + self.volumes['shared-{}'.format(group_id)] = { + 'bind': '/home/jovyan/%s'%(group_id), + 'mode': 'ro', + } if self.user.name == 'hub-admin': # if admin, allow userlist access self.volumes['%s/userlist'%(os.environ['HUB_LOC'])] = { 'bind': '/home/jovyan/userlist', 'mode': 'rw' } From e2a6df840030b81cd7792ec384bc311b168c0de0 Mon Sep 17 00:00:00 2001 From: mathematicalmichael Date: Mon, 18 Feb 2019 21:35:07 -0700 Subject: [PATCH 12/18] permissions fixed on setup --- setup.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/setup.sh b/setup.sh index 257ddb8..f19585a 100755 --- a/setup.sh +++ b/setup.sh @@ -5,6 +5,11 @@ # create a default userlist echo "Use the format \"studentname HUB_NAME-group1\" on each line to add students to groups (10 by default have already been created and permissions appropriately set)" > userlist echo "hub-admin admin shared" >> userlist + +# change permissions so that admins can edit these. +sudo chmod 777 userlist +sudo chmod 777 jupyterhub_config.py + mkdir secrets make secrets/oauth.env make secrets/postgres.env From 6f84c36108fe32b397ec733b4c759e1d3bf85b46 Mon Sep 17 00:00:00 2001 From: mathematicalmichael Date: Mon, 18 Feb 2019 21:49:56 -0700 Subject: [PATCH 13/18] changing how admins are parsed. --- jupyterhub_config.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/jupyterhub_config.py b/jupyterhub_config.py index 4df61f7..6b9db57 100755 --- a/jupyterhub_config.py +++ b/jupyterhub_config.py @@ -50,11 +50,13 @@ class MyDockerSpawner(DockerSpawner): 'bind': '/home/jovyan/%s'%(group_id), 'mode': 'ro', } - if self.user.name == 'hub-admin': # if admin, allow userlist access - self.volumes['%s/userlist'%(os.environ['HUB_LOC'])] = { 'bind': '/home/jovyan/userlist', - 'mode': 'rw' } - self.volumes['%s/jupyterhub_config.py'%(os.environ['HUB_LOC'])] = { 'bind': '/home/jovyan/jupyterhub_config.py', - 'mode': 'rw' } + else: # if admin is one of the groups in userlist, mount the following: + self.volumes['%s/userlist'%(os.environ['HUB_LOC'])] = \ + { 'bind': '/home/jovyan/userlist', 'mode': 'rw' } + self.volumes['%s/jupyterhub_config.py'%(os.environ['HUB_LOC'])] = \ + { 'bind': '/home/jovyan/jupyterhub_config.py', 'mode': 'rw' } + #self.volumes["/tmp/.X11-unix"] = {'bind': '/tmp/.X11-unix', 'mode': 'rw'} + #self.volumes["/home/pilosovm/.Xauthority"] = {'bind': '/root/.Xauthority', 'mode': 'rw'} return super().start() c.JupyterHub.spawner_class = MyDockerSpawner From a6cbe59e5481809360f2cfda1c7e376eed03d918 Mon Sep 17 00:00:00 2001 From: mathematicalmichael Date: Mon, 18 Feb 2019 22:02:07 -0700 Subject: [PATCH 14/18] updated volumes. --- jupyterhub_config.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/jupyterhub_config.py b/jupyterhub_config.py index 6b9db57..88e8522 100755 --- a/jupyterhub_config.py +++ b/jupyterhub_config.py @@ -55,8 +55,6 @@ class MyDockerSpawner(DockerSpawner): { 'bind': '/home/jovyan/userlist', 'mode': 'rw' } self.volumes['%s/jupyterhub_config.py'%(os.environ['HUB_LOC'])] = \ { 'bind': '/home/jovyan/jupyterhub_config.py', 'mode': 'rw' } - #self.volumes["/tmp/.X11-unix"] = {'bind': '/tmp/.X11-unix', 'mode': 'rw'} - #self.volumes["/home/pilosovm/.Xauthority"] = {'bind': '/root/.Xauthority', 'mode': 'rw'} return super().start() c.JupyterHub.spawner_class = MyDockerSpawner From d8e6d632db5d3b2f1d6c488a945c9e0509963430 Mon Sep 17 00:00:00 2001 From: mathematicalmichael Date: Mon, 18 Feb 2019 22:03:44 -0700 Subject: [PATCH 15/18] comments --- jupyterhub_config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jupyterhub_config.py b/jupyterhub_config.py index 88e8522..059c4b7 100755 --- a/jupyterhub_config.py +++ b/jupyterhub_config.py @@ -38,7 +38,7 @@ class MyDockerSpawner(DockerSpawner): if self.user.name in self.group_map: group_list = self.group_map[self.user.name] # add team volume to volumes - for group_id in group_list: # one superuser gets upload rights. + for group_id in group_list: # admins in userlist get to write files. if group_id != 'admin': if 'admin' in group_list: self.volumes['shared-{}'.format(group_id)] = { From 916eb2d21d569b0b99bd7baed0303e552a9168ee Mon Sep 17 00:00:00 2001 From: Michael Pilosov Date: Tue, 19 Feb 2019 05:20:34 +0000 Subject: [PATCH 16/18] setup --- setup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.sh b/setup.sh index f19585a..e052792 100755 --- a/setup.sh +++ b/setup.sh @@ -3,7 +3,7 @@ # this script is meant to be run only the first time a hub is being set up. # create a default userlist -echo "Use the format \"studentname HUB_NAME-group1\" on each line to add students to groups (10 by default have already been created and permissions appropriately set)" > userlist +# Use the format \"studentname HUB_NAME-group1\" on each line to add students to groups (10 by default have already been created and permissions appropriately set)" echo "hub-admin admin shared" >> userlist # change permissions so that admins can edit these. From c46bb606e109eeee227105e3fc0131b62875d33c Mon Sep 17 00:00:00 2001 From: Michael Pilosov Date: Tue, 19 Feb 2019 23:53:18 +0000 Subject: [PATCH 17/18] fixed tab error. --- jupyterhub_config.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/jupyterhub_config.py b/jupyterhub_config.py index 059c4b7..1470f4b 100755 --- a/jupyterhub_config.py +++ b/jupyterhub_config.py @@ -41,15 +41,13 @@ class MyDockerSpawner(DockerSpawner): for group_id in group_list: # admins in userlist get to write files. if group_id != 'admin': if 'admin' in group_list: - self.volumes['shared-{}'.format(group_id)] = { - 'bind': '/home/jovyan/%s'%(group_id), - 'mode': 'rw', # or ro for read-only - } + self.volumes['shared-{}'.format(group_id)] = \ + { 'bind': '/home/jovyan/%s'%(group_id), + 'mode': 'rw' } # or ro for read-only else: # this "shared-" is part of the naming convention - self.volumes['shared-{}'.format(group_id)] = { - 'bind': '/home/jovyan/%s'%(group_id), - 'mode': 'ro', - } + self.volumes['shared-{}'.format(group_id)] = \ + {'bind': '/home/jovyan/%s'%(group_id), + 'mode': 'ro' } # or rw for write (can cause conflicts) else: # if admin is one of the groups in userlist, mount the following: self.volumes['%s/userlist'%(os.environ['HUB_LOC'])] = \ { 'bind': '/home/jovyan/userlist', 'mode': 'rw' } From 1bb98bf1eb371e27d44092bbf7fa371fbd6279ea Mon Sep 17 00:00:00 2001 From: mathematicalmichael Date: Tue, 5 Mar 2019 17:06:13 -0700 Subject: [PATCH 18/18] version lock dockerspawner due to breaking changes. --- Dockerfile.jupyterhub | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile.jupyterhub b/Dockerfile.jupyterhub index 672ab9e..afb3125 100755 --- a/Dockerfile.jupyterhub +++ b/Dockerfile.jupyterhub @@ -15,7 +15,7 @@ RUN apt-get update && \ RUN apt-get clean && \ rm -rf /var/lib/apt/lists/* -RUN pip install jupyterhub-hashauthenticator git+https://github.com/jupyterhub/dockerspawner.git@master +RUN pip install jupyterhub-hashauthenticator dockerspawner==0.10.0 # Copy TLS certificate and key #ENV SSL_CERT /srv/jupyterhub/secrets/jupyterhub.crt