Skip to content

Commit

Permalink
add singleuser build dir from dockerspawner
Browse files Browse the repository at this point in the history
  • Loading branch information
minrk committed Aug 18, 2017
1 parent 48f1da1 commit 1e6b94d
Show file tree
Hide file tree
Showing 7 changed files with 88 additions and 1 deletion.
4 changes: 4 additions & 0 deletions .dockerignore
Expand Up @@ -4,3 +4,7 @@ jupyterhub_cookie_secret
jupyterhub.sqlite
jupyterhub_config.py
node_modules
docs
.git
dist
build
2 changes: 1 addition & 1 deletion .gitignore
Expand Up @@ -3,7 +3,7 @@ node_modules
*~
.cache
.DS_Store
build
/build
dist
docs/_build
docs/source/_static/rest-api
Expand Down
9 changes: 9 additions & 0 deletions singleuser/Dockerfile
@@ -0,0 +1,9 @@
# Build as jupyterhub/singleuser
# Run with the DockerSpawner in JupyterHub

FROM jupyter/base-notebook:5ded1de07260
MAINTAINER Project Jupyter <jupyter@googlegroups.com>

ADD install_jupyterhub /tmp/install_jupyterhub
ARG JUPYTERHUB_VERSION=master
RUN python /tmp/install_jupyterhub
20 changes: 20 additions & 0 deletions singleuser/README.md
@@ -0,0 +1,20 @@
# jupyterhub/singleuser

Built from the `jupyter/base-notebook` base image.

This image contains a single user notebook server for use with
[JupyterHub](https://github.com/jupyterhub/jupyterhub). In particular, it is meant
to be used with the
[DockerSpawner](https://github.com/jupyterhub/dockerspawner/blob/master/dockerspawner/dockerspawner.py)
class to launch user notebook servers within docker containers.


This particular server runs (within the container) as the `jovyan` user, with
home directory at `/home/jovyan`, and the IPython example notebooks at
`/home/jovyan/examples`.

## Note on persistence

This home directory, `/home/jovyan`, is *not* persistent by default,
so some configuration is required unless the directory is to be used
with temporary or demonstration JupyterHub deployments.
11 changes: 11 additions & 0 deletions singleuser/hooks/build
@@ -0,0 +1,11 @@
#!/bin/bash
set -ex

stable=0.7

for V in master 0.7; do
docker build --build-arg JUPYTERHUB_VERSION=$V -t $DOCKER_REPO:$V .
done

echo "tagging $IMAGE_NAME"
docker tag $DOCKER_REPO:$stable $IMAGE_NAME
23 changes: 23 additions & 0 deletions singleuser/hooks/post_push
@@ -0,0 +1,23 @@
#!/bin/bash

for V in master 0.7; do
docker push $DOCKER_REPO:$V
done

function get_hub_version() {
rm -f hub_version
V=$1
docker run --rm -v $PWD:/version -u $(id -u) -i $DOCKER_REPO:$V sh -c 'jupyterhub --version > /version/hub_version'
hub_xyz=$(cat hub_version)
split=( ${hub_xyz//./ } )
hub_xy="${split[0]}.${split[1]}"
}
# tag e.g. 0.7.2 with 0.7
get_hub_version 0.7
docker tag $DOCKER_REPO:0.7 $DOCKER_REPO:$hub_xyz
docker push $DOCKER_REPO:$hub_xyz

# tag e.g. 0.8 with master
get_hub_version master
docker tag $DOCKER_REPO:master $DOCKER_REPO:$hub_xy
docker push $DOCKER_REPO:$hub_xy
20 changes: 20 additions & 0 deletions singleuser/install_jupyterhub
@@ -0,0 +1,20 @@
#!/usr/bin/env python
import os
from subprocess import check_call

V = os.environ['JUPYTERHUB_VERSION']

pip_install = [
'pip', 'install', '--no-cache', '--upgrade',
'--upgrade-strategy', 'only-if-needed',
]
if V == 'master':
req = 'https://github.com/jupyterhub/jupyterhub/archive/master.tar.gz'
else:
version_info = [ int(part) for part in V.split('.') ]
version_info[-1] += 1
upper_bound = '.'.join(map(str, version_info))
vs = '>=%s,<%s' % (V, upper_bound)
req = 'jupyterhub%s' % vs

check_call(pip_install + [req])

0 comments on commit 1e6b94d

Please sign in to comment.