From 66c1815a785510a9caf92074ee37c9aa719862b2 Mon Sep 17 00:00:00 2001 From: Ankit Date: Tue, 21 Nov 2017 10:25:06 -0500 Subject: [PATCH 01/13] creating a simple docker compose environment to isolate jupyterhub notebook from other parts like configurable proxy --- docker-compose.yaml | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 docker-compose.yaml diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 00000000..40a8287f --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,8 @@ +version: '3' + +services: + proxy: + env_file: + - auth_token.env + image: jupyter/configurable-http-proxy + From b8a63bcc0c6f23340665ee8b1b9cf113bbb8e5d4 Mon Sep 17 00:00:00 2001 From: Ankit Date: Tue, 21 Nov 2017 10:26:28 -0500 Subject: [PATCH 02/13] auth env blank file --- auth_token.env | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 auth_token.env diff --git a/auth_token.env b/auth_token.env new file mode 100644 index 00000000..913e5c6b --- /dev/null +++ b/auth_token.env @@ -0,0 +1,4 @@ +# Regenerate this file by getting new value running the following command +# openssl rand -hex 32 > auth_token.env + +CONFIGPROXY_AUTH_TOKEN="" From acc60bce57cee873d4be3ab71fede29113e42060 Mon Sep 17 00:00:00 2001 From: Ankit Date: Tue, 21 Nov 2017 11:35:58 -0500 Subject: [PATCH 03/13] wip --- auth_token.env | 2 +- docker-compose.yaml | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/auth_token.env b/auth_token.env index 913e5c6b..8056d2ec 100644 --- a/auth_token.env +++ b/auth_token.env @@ -1,4 +1,4 @@ # Regenerate this file by getting new value running the following command # openssl rand -hex 32 > auth_token.env -CONFIGPROXY_AUTH_TOKEN="" +CONFIGPROXY_AUTH_TOKEN="4e8bbc40183ee760447c6331f8b2fa90940ceae39c0b5d9abe58bf1b301b727d" diff --git a/docker-compose.yaml b/docker-compose.yaml index 40a8287f..7b76a196 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -5,4 +5,22 @@ services: env_file: - auth_token.env image: jupyter/configurable-http-proxy + networks: + - jupyterhub + + hub: + depends_on: + - proxy + env_file: + - auth_token.env + image: python:3.6.3-alpine3.6 + networks: + - jupyterhub + command: "python -m http.server" + +networks: + jupyterhub: + + + From 457bea7c3495dd14e8fad0ce4ccda227dd29fb9e Mon Sep 17 00:00:00 2001 From: Ankit Date: Tue, 21 Nov 2017 13:01:21 -0500 Subject: [PATCH 04/13] Base dockerfile --- Dockerfile | 66 +++------------------------------------------ docker-compose.yaml | 11 +++++--- 2 files changed, 10 insertions(+), 67 deletions(-) diff --git a/Dockerfile b/Dockerfile index c95b2f9a..27e10f75 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,65 +1,5 @@ -# An incomplete base Docker image for running JupyterHub -# -# Add your configuration to create a complete derivative Docker image. -# -# Include your configuration settings by starting with one of two options: -# -# Option 1: -# -# FROM jupyterhub/jupyterhub:latest -# -# And put your configuration file jupyterhub_config.py in /srv/jupyterhub/jupyterhub_config.py. -# -# Option 2: -# -# Or you can create your jupyterhub config and database on the host machine, and mount it with: -# -# docker run -v $PWD:/srv/jupyterhub -t jupyterhub/jupyterhub -# -# NOTE -# If you base on jupyterhub/jupyterhub-onbuild -# your jupyterhub_config.py will be added automatically -# from your docker directory. +FROM python:3.6.3-alpine3.6 +RUN pip3 install --no-cache jupyterhub==0.8.0 +ENV LANG=en_US.UTF-8 -FROM debian:jessie -MAINTAINER Jupyter Project -# install nodejs, utf8 locale, set CDN because default httpredir is unreliable -ENV DEBIAN_FRONTEND noninteractive -RUN REPO=http://cdn-fastly.deb.debian.org && \ - echo "deb $REPO/debian jessie main\ndeb $REPO/debian-security jessie/updates main" > /etc/apt/sources.list && \ - apt-get -y update && \ - apt-get -y upgrade && \ - apt-get -y install wget locales git bzip2 &&\ - /usr/sbin/update-locale LANG=C.UTF-8 && \ - locale-gen C.UTF-8 && \ - apt-get remove -y locales && \ - apt-get clean && \ - rm -rf /var/lib/apt/lists/* -ENV LANG C.UTF-8 - -# install Python + NodeJS with conda -RUN wget -q https://repo.continuum.io/miniconda/Miniconda3-4.2.12-Linux-x86_64.sh -O /tmp/miniconda.sh && \ - echo 'd0c7c71cc5659e54ab51f2005a8d96f3 */tmp/miniconda.sh' | md5sum -c - && \ - bash /tmp/miniconda.sh -f -b -p /opt/conda && \ - /opt/conda/bin/conda install --yes -c conda-forge \ - python=3.5 sqlalchemy tornado jinja2 traitlets requests pip pycurl \ - nodejs configurable-http-proxy && \ - /opt/conda/bin/pip install --upgrade pip && \ - rm /tmp/miniconda.sh -ENV PATH=/opt/conda/bin:$PATH - -ADD . /src/jupyterhub -WORKDIR /src/jupyterhub - -RUN npm install --unsafe-perm && \ - pip install . && \ - rm -rf $PWD ~/.cache ~/.npm - -RUN mkdir -p /srv/jupyterhub/ -WORKDIR /srv/jupyterhub/ -EXPOSE 8000 - -LABEL org.jupyter.service="jupyterhub" - -CMD ["jupyterhub"] diff --git a/docker-compose.yaml b/docker-compose.yaml index 7b76a196..8259bb74 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -7,6 +7,11 @@ services: image: jupyter/configurable-http-proxy networks: - jupyterhub + # override entrypoint to expose api to the network + entrypoint: + - "configurable-http-proxy" + - "--api-ip=0.0.0.0" + - "--api-port=8001" hub: depends_on: @@ -17,10 +22,8 @@ services: networks: - jupyterhub command: "python -m http.server" + volumes: + - ./:/home/jupyterhub networks: jupyterhub: - - - - From 0cca79eeee10103c4270bf78927ac8d3cf6a7f52 Mon Sep 17 00:00:00 2001 From: Ankit Date: Tue, 21 Nov 2017 13:03:25 -0500 Subject: [PATCH 05/13] auth token instructions updated --- auth_token.env | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/auth_token.env b/auth_token.env index 8056d2ec..257400ef 100644 --- a/auth_token.env +++ b/auth_token.env @@ -1,4 +1,4 @@ # Regenerate this file by getting new value running the following command -# openssl rand -hex 32 > auth_token.env +# openssl rand -hex 32 CONFIGPROXY_AUTH_TOKEN="4e8bbc40183ee760447c6331f8b2fa90940ceae39c0b5d9abe58bf1b301b727d" From d9a0a2003f09ec8bf7a521f24b491603fd3aff77 Mon Sep 17 00:00:00 2001 From: Ankit Date: Tue, 21 Nov 2017 13:23:21 -0500 Subject: [PATCH 06/13] moving base dockerfile into a directory --- Dockerfile | 66 +++++++++++++++++++++++++++++++++++-- dockerfiles/Dockerfile.base | 5 +++ 2 files changed, 68 insertions(+), 3 deletions(-) create mode 100644 dockerfiles/Dockerfile.base diff --git a/Dockerfile b/Dockerfile index 27e10f75..c95b2f9a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,65 @@ -FROM python:3.6.3-alpine3.6 -RUN pip3 install --no-cache jupyterhub==0.8.0 -ENV LANG=en_US.UTF-8 +# An incomplete base Docker image for running JupyterHub +# +# Add your configuration to create a complete derivative Docker image. +# +# Include your configuration settings by starting with one of two options: +# +# Option 1: +# +# FROM jupyterhub/jupyterhub:latest +# +# And put your configuration file jupyterhub_config.py in /srv/jupyterhub/jupyterhub_config.py. +# +# Option 2: +# +# Or you can create your jupyterhub config and database on the host machine, and mount it with: +# +# docker run -v $PWD:/srv/jupyterhub -t jupyterhub/jupyterhub +# +# NOTE +# If you base on jupyterhub/jupyterhub-onbuild +# your jupyterhub_config.py will be added automatically +# from your docker directory. +FROM debian:jessie +MAINTAINER Jupyter Project +# install nodejs, utf8 locale, set CDN because default httpredir is unreliable +ENV DEBIAN_FRONTEND noninteractive +RUN REPO=http://cdn-fastly.deb.debian.org && \ + echo "deb $REPO/debian jessie main\ndeb $REPO/debian-security jessie/updates main" > /etc/apt/sources.list && \ + apt-get -y update && \ + apt-get -y upgrade && \ + apt-get -y install wget locales git bzip2 &&\ + /usr/sbin/update-locale LANG=C.UTF-8 && \ + locale-gen C.UTF-8 && \ + apt-get remove -y locales && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* +ENV LANG C.UTF-8 + +# install Python + NodeJS with conda +RUN wget -q https://repo.continuum.io/miniconda/Miniconda3-4.2.12-Linux-x86_64.sh -O /tmp/miniconda.sh && \ + echo 'd0c7c71cc5659e54ab51f2005a8d96f3 */tmp/miniconda.sh' | md5sum -c - && \ + bash /tmp/miniconda.sh -f -b -p /opt/conda && \ + /opt/conda/bin/conda install --yes -c conda-forge \ + python=3.5 sqlalchemy tornado jinja2 traitlets requests pip pycurl \ + nodejs configurable-http-proxy && \ + /opt/conda/bin/pip install --upgrade pip && \ + rm /tmp/miniconda.sh +ENV PATH=/opt/conda/bin:$PATH + +ADD . /src/jupyterhub +WORKDIR /src/jupyterhub + +RUN npm install --unsafe-perm && \ + pip install . && \ + rm -rf $PWD ~/.cache ~/.npm + +RUN mkdir -p /srv/jupyterhub/ +WORKDIR /srv/jupyterhub/ +EXPOSE 8000 + +LABEL org.jupyter.service="jupyterhub" + +CMD ["jupyterhub"] diff --git a/dockerfiles/Dockerfile.base b/dockerfiles/Dockerfile.base new file mode 100644 index 00000000..27e10f75 --- /dev/null +++ b/dockerfiles/Dockerfile.base @@ -0,0 +1,5 @@ +FROM python:3.6.3-alpine3.6 +RUN pip3 install --no-cache jupyterhub==0.8.0 +ENV LANG=en_US.UTF-8 + + From 089a12bdc934035911fee51240a836276943f7d8 Mon Sep 17 00:00:00 2001 From: Ankit Date: Tue, 21 Nov 2017 13:32:59 -0500 Subject: [PATCH 07/13] adding a readme --- dockerfiles/README.md | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 dockerfiles/README.md diff --git a/dockerfiles/README.md b/dockerfiles/README.md new file mode 100644 index 00000000..673b2bd7 --- /dev/null +++ b/dockerfiles/README.md @@ -0,0 +1,11 @@ +Dockerfile.base contains base image for jupyterhub. It does not work independently. To make it work it needs + +1. A running configurable-http-proxy, whose API is accessible. +2. A jupyterhub_config file. +3. Authentication and other libraries required by the specific jupyterhub_config file. + +An example on how to use this base image is in docker-compose.yaml. You can run it by doing +``` +docker-compose up +``` +to run it. From b38c6fe06a8556aa430df519e23afae1f771a7f5 Mon Sep 17 00:00:00 2001 From: Ankit Date: Tue, 21 Nov 2017 13:42:50 -0500 Subject: [PATCH 08/13] added readme and started working on config image --- dockerfiles/Dockerfile.config | 6 ++++++ dockerfiles/README.md | 15 +++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 dockerfiles/Dockerfile.config diff --git a/dockerfiles/Dockerfile.config b/dockerfiles/Dockerfile.config new file mode 100644 index 00000000..dd97b95d --- /dev/null +++ b/dockerfiles/Dockerfile.config @@ -0,0 +1,6 @@ +FROM ankitml/jupyterhub-base + + + +USER nobody +ENTRYPOINT ["jupyterhub"] diff --git a/dockerfiles/README.md b/dockerfiles/README.md index 673b2bd7..fe8e028f 100644 --- a/dockerfiles/README.md +++ b/dockerfiles/README.md @@ -1,11 +1,22 @@ +## What is Dockerfile.base Dockerfile.base contains base image for jupyterhub. It does not work independently. To make it work it needs +## How to use it? + 1. A running configurable-http-proxy, whose API is accessible. 2. A jupyterhub_config file. 3. Authentication and other libraries required by the specific jupyterhub_config file. -An example on how to use this base image is in docker-compose.yaml. You can run it by doing +## Example +* An example of how to use this base image and add customizations is in Dockerfile.config. +* A complete example on how to use this base image and config image is in docker-compose.yaml. To test it you can run ``` docker-compose up ``` -to run it. + +## Reference +* Build an image from Dockerfile.base and push it to a docker registry (e.g https://hub.docker.com/r/ankitml/jupyterhub-base/) +* Build the config image from Dockerfile.config and push it to a docker registry (e.g https://hub.docker.com/r/ankitml/jupyterhub-config) +* Use this image in your cluster either from docker-compose example or kubernetes tutorial. + + From 04675e5fcb9c97f8cf24e990de801e9abb01108e Mon Sep 17 00:00:00 2001 From: Ankit Date: Tue, 21 Nov 2017 13:50:43 -0500 Subject: [PATCH 09/13] removed compose and env file --- auth_token.env | 4 ---- docker-compose.yaml | 29 ----------------------------- dockerfiles/README.md | 2 +- 3 files changed, 1 insertion(+), 34 deletions(-) delete mode 100644 auth_token.env delete mode 100644 docker-compose.yaml diff --git a/auth_token.env b/auth_token.env deleted file mode 100644 index 257400ef..00000000 --- a/auth_token.env +++ /dev/null @@ -1,4 +0,0 @@ -# Regenerate this file by getting new value running the following command -# openssl rand -hex 32 - -CONFIGPROXY_AUTH_TOKEN="4e8bbc40183ee760447c6331f8b2fa90940ceae39c0b5d9abe58bf1b301b727d" diff --git a/docker-compose.yaml b/docker-compose.yaml deleted file mode 100644 index 8259bb74..00000000 --- a/docker-compose.yaml +++ /dev/null @@ -1,29 +0,0 @@ -version: '3' - -services: - proxy: - env_file: - - auth_token.env - image: jupyter/configurable-http-proxy - networks: - - jupyterhub - # override entrypoint to expose api to the network - entrypoint: - - "configurable-http-proxy" - - "--api-ip=0.0.0.0" - - "--api-port=8001" - - hub: - depends_on: - - proxy - env_file: - - auth_token.env - image: python:3.6.3-alpine3.6 - networks: - - jupyterhub - command: "python -m http.server" - volumes: - - ./:/home/jupyterhub - -networks: - jupyterhub: diff --git a/dockerfiles/README.md b/dockerfiles/README.md index fe8e028f..c2127e86 100644 --- a/dockerfiles/README.md +++ b/dockerfiles/README.md @@ -1,5 +1,5 @@ ## What is Dockerfile.base -Dockerfile.base contains base image for jupyterhub. It does not work independently. To make it work it needs +Dockerfile.base contains base image for jupyterhub. It does not work independently, but only as part of a full jupyterhub cluster ## How to use it? From 151d6cbc48660024a5d74b9e8d9c55b4e2a7523d Mon Sep 17 00:00:00 2001 From: Ankit Date: Tue, 21 Nov 2017 13:53:39 -0500 Subject: [PATCH 10/13] updated readme --- dockerfiles/README.md | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/dockerfiles/README.md b/dockerfiles/README.md index c2127e86..4c3b7365 100644 --- a/dockerfiles/README.md +++ b/dockerfiles/README.md @@ -7,16 +7,15 @@ Dockerfile.base contains base image for jupyterhub. It does not work independent 2. A jupyterhub_config file. 3. Authentication and other libraries required by the specific jupyterhub_config file. -## Example -* An example of how to use this base image and add customizations is in Dockerfile.config. -* A complete example on how to use this base image and config image is in docker-compose.yaml. To test it you can run -``` -docker-compose up -``` -## Reference -* Build an image from Dockerfile.base and push it to a docker registry (e.g https://hub.docker.com/r/ankitml/jupyterhub-base/) -* Build the config image from Dockerfile.config and push it to a docker registry (e.g https://hub.docker.com/r/ankitml/jupyterhub-config) -* Use this image in your cluster either from docker-compose example or kubernetes tutorial. +## Steps to test it outside a cluster +* start configurable-http-proxy in another container +* specify CONFIGPROXY_AUTH_TOKEN env in both containers +* put both containers on the same network (e.g. docker create network jupyterhub; docker run ... --net jupyterhub) +* tell jupyterhub where CHP is (e.g. c.ConfigurableHTTPProxy.api_url = 'http://chp:8001') +* tell jupyterhub not to start the proxy itself (`c.ConfigurableHTTPProxy.should_start = False) +* Use dummy authenticator for ease of testing. Update following in jupyterhub_config file + - c.JupyterHub.authenticator_class = 'dummyauthenticator.DummyAuthenticator' + - c.DummyAuthenticator.password = "your strong password" From fd260cf32f3b9613c06541cecd050996782e0c08 Mon Sep 17 00:00:00 2001 From: Ankit Date: Tue, 21 Nov 2017 13:58:22 -0500 Subject: [PATCH 11/13] updated base name --- dockerfiles/{Dockerfile.base => Dockerfile.alpine} | 0 dockerfiles/Dockerfile.config | 3 ++- dockerfiles/README.md | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) rename dockerfiles/{Dockerfile.base => Dockerfile.alpine} (100%) diff --git a/dockerfiles/Dockerfile.base b/dockerfiles/Dockerfile.alpine similarity index 100% rename from dockerfiles/Dockerfile.base rename to dockerfiles/Dockerfile.alpine diff --git a/dockerfiles/Dockerfile.config b/dockerfiles/Dockerfile.config index dd97b95d..25c6a971 100644 --- a/dockerfiles/Dockerfile.config +++ b/dockerfiles/Dockerfile.config @@ -1,6 +1,7 @@ FROM ankitml/jupyterhub-base - +# change the jupyterhub_config file to point to proxy, +# or mount the correct volume for jupyterhub_config USER nobody ENTRYPOINT ["jupyterhub"] diff --git a/dockerfiles/README.md b/dockerfiles/README.md index 4c3b7365..88b0fe7e 100644 --- a/dockerfiles/README.md +++ b/dockerfiles/README.md @@ -14,7 +14,7 @@ Dockerfile.base contains base image for jupyterhub. It does not work independent * specify CONFIGPROXY_AUTH_TOKEN env in both containers * put both containers on the same network (e.g. docker create network jupyterhub; docker run ... --net jupyterhub) * tell jupyterhub where CHP is (e.g. c.ConfigurableHTTPProxy.api_url = 'http://chp:8001') -* tell jupyterhub not to start the proxy itself (`c.ConfigurableHTTPProxy.should_start = False) +* tell jupyterhub not to start the proxy itself (c.ConfigurableHTTPProxy.should_start = False) * Use dummy authenticator for ease of testing. Update following in jupyterhub_config file - c.JupyterHub.authenticator_class = 'dummyauthenticator.DummyAuthenticator' - c.DummyAuthenticator.password = "your strong password" From b873149f9be9eb54c80be3571629940d819dcce5 Mon Sep 17 00:00:00 2001 From: Ankit Date: Tue, 21 Nov 2017 14:04:25 -0500 Subject: [PATCH 12/13] updated alpine according to PR comments --- dockerfiles/Dockerfile.alpine | 3 +++ dockerfiles/Dockerfile.config | 7 ------- dockerfiles/README.md | 4 ++-- 3 files changed, 5 insertions(+), 9 deletions(-) delete mode 100644 dockerfiles/Dockerfile.config diff --git a/dockerfiles/Dockerfile.alpine b/dockerfiles/Dockerfile.alpine index 27e10f75..0fd10a3c 100644 --- a/dockerfiles/Dockerfile.alpine +++ b/dockerfiles/Dockerfile.alpine @@ -2,4 +2,7 @@ FROM python:3.6.3-alpine3.6 RUN pip3 install --no-cache jupyterhub==0.8.0 ENV LANG=en_US.UTF-8 +USER nobody +ENTRYPOINT ["jupyterhub"] + diff --git a/dockerfiles/Dockerfile.config b/dockerfiles/Dockerfile.config deleted file mode 100644 index 25c6a971..00000000 --- a/dockerfiles/Dockerfile.config +++ /dev/null @@ -1,7 +0,0 @@ -FROM ankitml/jupyterhub-base - -# change the jupyterhub_config file to point to proxy, -# or mount the correct volume for jupyterhub_config - -USER nobody -ENTRYPOINT ["jupyterhub"] diff --git a/dockerfiles/README.md b/dockerfiles/README.md index 88b0fe7e..e095b85f 100644 --- a/dockerfiles/README.md +++ b/dockerfiles/README.md @@ -1,5 +1,5 @@ -## What is Dockerfile.base -Dockerfile.base contains base image for jupyterhub. It does not work independently, but only as part of a full jupyterhub cluster +## What is Dockerfile.alpine +Dockerfile.alpine contains base image for jupyterhub. It does not work independently, but only as part of a full jupyterhub cluster ## How to use it? From 138b2be010ce9c9d5937ba54a955bca712527c7b Mon Sep 17 00:00:00 2001 From: Ankit Date: Mon, 4 Dec 2017 11:41:56 -0500 Subject: [PATCH 13/13] updated CMD and jupyterhub version is put into argument --- dockerfiles/Dockerfile.alpine | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/dockerfiles/Dockerfile.alpine b/dockerfiles/Dockerfile.alpine index 0fd10a3c..ab2fb1d5 100644 --- a/dockerfiles/Dockerfile.alpine +++ b/dockerfiles/Dockerfile.alpine @@ -1,8 +1,11 @@ FROM python:3.6.3-alpine3.6 -RUN pip3 install --no-cache jupyterhub==0.8.0 + +ARG JUPYTERHUB_VERSION=0.8.1 + +RUN pip3 install --no-cache jupyterhub==${JUPYTERHUB_VERSION} ENV LANG=en_US.UTF-8 USER nobody -ENTRYPOINT ["jupyterhub"] +CMD ["jupyterhub"]