diff --git a/README.md b/README.md index c61305d3f211111888e74a0076b3e2d2ba57cf2b..f2eb22f2b4736e4836442cec8e6726d9c74dfc2c 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,20 @@ As suggested by [playermanny2](https://github.com/jupyterhub/dockerspawner/issue we'll start with a simple use case launching jupyter/minimal-notebook to make sure all is working. Then we'll try with a custom image like rocker/binder. + +<p align="center"> + <img src="./readme.img/idg-jupyhterhub-oauht.gif" alt="idg-jupyhterhub-oauht" width="500"/> +</p> + +Table of Contents +================= ++ [Start python notebook](#minimal-notebook) ++ [Start rstudio IDE](#rstudio) ++ [Custom configuration](#custom-configuration) + + [Authentification with Gitlab's OAuth](#adding-gitlab-oauth) + + [Change Jupyterhub URL for reverse-proxification](#change-hub-url) + + ## minimal-notebook The minimal tree is: @@ -122,6 +136,56 @@ The following code should remove jupyterhub and user containers respectively. docker-compose down && docker rm $(docker ps -qa -f "name=jupyter-") ``` +## Rstudio + +An Rstudio-session can be launched from inside a jupyterlab session with +[jupyter-rsession-proxy](https://github.com/jupyterhub/jupyter-rsession-proxy). + +The docker image [rocker/binder](https://rocker-project.org/images/versioned/binder.html) and +specially script [install_jupyter.sh](https://github.com/rocker-org/rocker-versioned2/blob/master/scripts/install_jupyter.sh) +gives a good example of how it can be done. Actually it installs JupyterLab, jupyter-rsession-proxy and IRkernel +on top of the rocker/geospatial image, and defines the default command with jupyterhub-singleuser +making the container controllable by jupyterhub. + +The directory `jupyterhub-rstudio` shows an example of such a configuration. + +Following [jupyterhub documentation](https://jupyterhub-dockerspawner.readthedocs.io/en/latest/docker-image.html#how-to-build-your-own-docker-image) +the image rocker/binder is adapted to be spawn by jupyterhub: +```docker +FROM rocker/binder:4.2.1 + +ARG JUPYTERHUB_VERSION=3.0.0 +USER root +RUN pip3 install --no-cache \ + jupyterhub==$JUPYTERHUB_VERSION + +USER ${NB_USER} +WORKDIR /home/${NB_USER} +CMD ["jupyterhub-singleuser"] +``` +One can notice that no user is created as there is a default user named "rstudio" in rocker images. + +A section is then added to `docker-compose.yml` in order to configure the build of rstudio image, named here `rstudio_img` +and its call by jupyterhub. + +Use command lines of section [Build and run] to run and access the server. + +## Custom configuration +### Adding GitLab OAuth + +Directory `jupyterhub-rstudio-gitlab` is showing an example with on the way to configure jupyterhub in order to call GitLab OAuth +as authenticator. In order to do so: + +- package oautenticator is installed in jupyterhub docker image. +- an application has to be defined in gitlab user settings: it needs scope read_user. +The URI is defined with https://<jupyterhub server>/hub/oauth_callback. + - <img src="./readme.img/jupyterhub_gitlab_irstea_oauht2.png" alt="jupyterhub_gitlab_irstea_oauht2" width="500"/> +- It's possible to define a self hosted gitlab by using the environnement variable `GITLAB_URL` +- a section is added in jupyterhub_config.py using the URI, the client ID and client secret defined in the gitlab application. +These variables are stored in .env file and called in jupyterhub_config.py. + - Be **careful**: you should remove the comment (#) at the end of lines. + - After editing the .env, it has to be sourced: `source .env` + ### Change hub URL The the hub URL can be changed with `bind_url`. Example, if I want to route the hub to http://localhost/minimal_notebook @@ -139,7 +203,7 @@ services: volumes: # Give access to Docker socket. - /var/run/docker.sock:/var/run/docker.sock - ./jupyterhub/jupyterhub_config.py:/srv/jupyterhub/jupyterhub_config.py - environment: # Env variables passed to the Hub process. + environment: # Env variables passed to the Hub process.im DOCKER_JUPYTER_IMAGE: jupyter/minimal-notebook DOCKER_NETWORK_NAME: ${COMPOSE_PROJECT_NAME}_default HUB_IP: ${COMPOSE_PROJECT_NAME}_hub @@ -173,51 +237,6 @@ c.JupyterHub.bind_url = 'http://0.0.0.0:80/'+os.environ['COMPOSE_PROJECT_NAME'] However, with the docker port binding `80:80`, it wouldn't be possible to run another hub in parallel (e.g. for another tutorial). Thus rerouting outside the container would be a better solution (to be documented). -## Rstudio - -An Rstudio-session can be launched from inside a jupyterlab session with -[jupyter-rsession-proxy](https://github.com/jupyterhub/jupyter-rsession-proxy). - -The docker image [rocker/binder](https://rocker-project.org/images/versioned/binder.html) and -specially script [install_jupyter.sh](https://github.com/rocker-org/rocker-versioned2/blob/master/scripts/install_jupyter.sh) -gives a good example of how it can be done. Actually it installs JupyterLab, jupyter-rsession-proxy and IRkernel -on top of the rocker/geospatial image, and defines the default command with jupyterhub-singleuser -making the container controllable by jupyterhub. - -The directory `jupyterhub-rstudio` shows an example of such a configuration. - -Following [jupyterhub documentation](https://jupyterhub-dockerspawner.readthedocs.io/en/latest/docker-image.html#how-to-build-your-own-docker-image) -the image rocker/binder is adapted to be spawn by jupyterhub: -```docker -FROM rocker/binder:4.2.1 - -ARG JUPYTERHUB_VERSION=3.0.0 -USER root -RUN pip3 install --no-cache \ - jupyterhub==$JUPYTERHUB_VERSION - -USER ${NB_USER} -WORKDIR /home/${NB_USER} -CMD ["jupyterhub-singleuser"] -``` -One can notice that no user is created as there is a default user named "rstudio" in rocker images. - -A section is then added to `docker-compose.yml` in order to configure the build of rstudio image, named here `rstudio_img` -and its call by jupyterhub. - -Use command lines of section [Build and run] to run and access the server. - -## Adding GitLab OAuth - -Directory `jupyterhub-rstudio-gitlab` is showing an example with on the way to configure jupyterhub in order to call GitLab OAuth -as authenticator. In order to do so: -- package oautenticator is installed in jupyterhub docker image. -- an application has to be defined in gitlab user settings: it needs scope read_user. -The URI is defined with https://<jupyterhub server>/hub/oauth_callback. -- a section is added in jupyterhub_config.py using the URI, the client ID and client secret defined in the gitlab application. -These variables are stored in .env file and called in jupyterhub_config.py. - - # Authors diff --git a/readme.img/idg-jupyhterhub-oauht.gif b/readme.img/idg-jupyhterhub-oauht.gif new file mode 100644 index 0000000000000000000000000000000000000000..dc47d03cff5bd260b337c134519d4266362e1191 Binary files /dev/null and b/readme.img/idg-jupyhterhub-oauht.gif differ diff --git a/readme.img/jupyterhub_gitlab_irstea_oauht2.png b/readme.img/jupyterhub_gitlab_irstea_oauht2.png new file mode 100644 index 0000000000000000000000000000000000000000..c1d690e0fcb52c73fb53bdf352acf1e5849b7d23 Binary files /dev/null and b/readme.img/jupyterhub_gitlab_irstea_oauht2.png differ