Commit 258e25c0 authored by Kyle Kelley's avatar Kyle Kelley

Merge pull request #162 from minrk/singleuser

build JupyterHub singleuser images for each notebook stack
parents 630bb6f8 7f2be9cd
...@@ -61,3 +61,6 @@ target/ ...@@ -61,3 +61,6 @@ target/
# Mac OS X # Mac OS X
.DS_Store .DS_Store
dockerspawner
dockerspawner.tar.gz
\ No newline at end of file
...@@ -12,6 +12,11 @@ ALL_STACKS:=minimal-kernel \ ...@@ -12,6 +12,11 @@ ALL_STACKS:=minimal-kernel \
datascience-notebook \ datascience-notebook \
pyspark-notebook \ pyspark-notebook \
all-spark-notebook all-spark-notebook
ALL_SINGLEUSERS:=$(shell echo $(ALL_STACKS) | sed "s/ /\n/g" | grep notebook | sed s/notebook/singleuser/g)
ALL_IMAGES:=$(ALL_STACKS) $(ALL_SINGLEUSERS)
GIT_MASTER_HEAD_SHA:=$(shell git rev-parse --short=12 --verify HEAD) GIT_MASTER_HEAD_SHA:=$(shell git rev-parse --short=12 --verify HEAD)
help: help:
...@@ -24,10 +29,14 @@ help: ...@@ -24,10 +29,14 @@ help:
@echo ' tag/<stack-dirname> - tags the latest stack image with the HEAD git SHA' @echo ' tag/<stack-dirname> - tags the latest stack image with the HEAD git SHA'
build/%: DARGS?= build/%: DARGS?=
build/%-singleuser: build/%-notebook
./internal/build-singleuser $(OWNER)/$*-notebook $(OWNER)/$*-singleuser
build/%: build/%:
docker build $(DARGS) --rm --force-rm -t $(OWNER)/$(notdir $@):latest ./$(notdir $@) docker build $(DARGS) --rm --force-rm -t $(OWNER)/$(notdir $@):latest ./$(notdir $@)
build-all: $(patsubst %,build/%, $(ALL_STACKS)) build-all: $(patsubst %,build/%, $(ALL_IMAGES))
dev/%: ARGS?= dev/%: ARGS?=
dev/%: DARGS?= dev/%: DARGS?=
...@@ -42,18 +51,18 @@ push/%: ...@@ -42,18 +51,18 @@ push/%:
docker push $(OWNER)/$(notdir $@):latest docker push $(OWNER)/$(notdir $@):latest
docker push $(OWNER)/$(notdir $@):$(GIT_MASTER_HEAD_SHA) docker push $(OWNER)/$(notdir $@):$(GIT_MASTER_HEAD_SHA)
push-all: $(patsubst %,push/%, $(ALL_IMAGES))
refresh/%: refresh/%:
# skip if error: a stack might not be on dockerhub yet # skip if error: a stack might not be on dockerhub yet
-docker pull $(OWNER)/$(notdir $@):latest -docker pull $(OWNER)/$(notdir $@):latest
refresh-all: $(patsubst %,refresh/%, $(ALL_STACKS)) refresh-all: $(patsubst %,refresh/%, $(ALL_IMAGES))
release-all: environment-check \ release-all: environment-check refresh-all build-all tag-all push-all
$(patsubst %,refresh/%, $(ALL_STACKS)) \
$(patsubst %,build/%, $(ALL_STACKS)) \
$(patsubst %,tag/%, $(ALL_STACKS)) \
$(patsubst %,push/%, $(ALL_STACKS))
tag/%: tag/%:
# always tag the latest build with the git sha # always tag the latest build with the git sha
docker tag -f $(OWNER)/$(notdir $@):latest $(OWNER)/$(notdir $@):$(GIT_MASTER_HEAD_SHA) docker tag -f $(OWNER)/$(notdir $@):latest $(OWNER)/$(notdir $@):$(GIT_MASTER_HEAD_SHA)
tag-all: $(patsubst %,tag/%, $(ALL_IMAGES))
...@@ -26,6 +26,8 @@ If this is your first time using Docker or any of the Jupyter projects, do the f ...@@ -26,6 +26,8 @@ If this is your first time using Docker or any of the Jupyter projects, do the f
Starting with [git commit SHA 9bd33dcc8688](https://github.com/jupyter/docker-stacks/tree/9bd33dcc8688): Starting with [git commit SHA 9bd33dcc8688](https://github.com/jupyter/docker-stacks/tree/9bd33dcc8688):
* Every folder here on GitHub has an equivalent `jupyter/<stack name>` on Docker Hub. * Every folder here on GitHub has an equivalent `jupyter/<stack name>` on Docker Hub.
* Each `*-notebook` stack also has a corresponding `*-singleuser` stack,
for use with [JupyterHub](https://jupyterhub.readthedocs.org).
* The `latest` tag in each Docker Hub repository tracks the `master` branch `HEAD` reference on GitHub. * The `latest` tag in each Docker Hub repository tracks the `master` branch `HEAD` reference on GitHub.
* Any 12-character image tag on Docker Hub refers to a git commit SHA here on GitHub. See the [Docker build history wiki page](https://github.com/jupyter/docker-stacks/wiki/Docker-build-history) for a table of build details. * Any 12-character image tag on Docker Hub refers to a git commit SHA here on GitHub. See the [Docker build history wiki page](https://github.com/jupyter/docker-stacks/wiki/Docker-build-history) for a table of build details.
* Stack contents (e.g., new library versions) will be updated upon request via PRs against this project. * Stack contents (e.g., new library versions) will be updated upon request via PRs against this project.
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
* [tini](https://github.com/krallin/tini) as the container entrypoint and [start-notebook.sh](../minimal-notebook/start-notebook.sh) as the default command * [tini](https://github.com/krallin/tini) as the container entrypoint and [start-notebook.sh](../minimal-notebook/start-notebook.sh) as the default command
* Options for HTTPS, password auth, and passwordless `sudo` * Options for HTTPS, password auth, and passwordless `sudo`
## Basic Use ## Basic Use
The following command starts a container with the Notebook server listening for HTTP connections on port 8888 without authentication configured. The following command starts a container with the Notebook server listening for HTTP connections on port 8888 without authentication configured.
...@@ -240,3 +241,13 @@ source deactivate ...@@ -240,3 +241,13 @@ source deactivate
``` ```
The commands `ipython`, `python`, `pip`, `easy_install`, and `conda` (among others) are available in both environments. The commands `ipython`, `python`, `pip`, `easy_install`, and `conda` (among others) are available in both environments.
## JupyterHub
To use this stack with [JupyterHub](https://jupyterhub.readthedocs.org) and [DockerSpawner](https://github.com/jupyter/dockerspawner),
set
```python
c.DockerSpawner.container_image = 'jupyter/all-spark-singleuser'
```
...@@ -58,3 +58,13 @@ source deactivate ...@@ -58,3 +58,13 @@ source deactivate
``` ```
The commands `ipython`, `python`, `pip`, `easy_install`, and `conda` (among others) are available in both environments. The commands `ipython`, `python`, `pip`, `easy_install`, and `conda` (among others) are available in both environments.
## JupyterHub
To use this stack with [JupyterHub](https://jupyterhub.readthedocs.org) and [DockerSpawner](https://github.com/jupyter/dockerspawner),
set
```python
c.DockerSpawner.container_image = 'jupyter/datascience-singleuser'
```
#!/usr/bin/env bash
# Build a singleuser image for JupyterHub from a given stack
# Usage:
# ./build-singleuser jupyter/scipy-notebook my-singleuser-image
set -e
V="0.2.0"
# get dockerspawner
if [[ ! -d dockerspawner ]]; then
tgz="dockerspawner.tar.gz"
wget -N https://github.com/jupyter/dockerspawner/archive/$V.tar.gz -O $tgz
echo "8af14608ad30df4dfcced7c7be508d336d485d9c31af965dc84c5e882e19dfe4 *$tgz" | shasum -a 256 -c - || (echo "shasum mismatch $(shasum -a 256 $tgz)" && exit -1)
tar -xzf $tgz
mv dockerspawner-$V dockerspawner
fi
base="$1"
name="$2"
if [[ -z "$base" || -z "$name" ]]; then
echo "Usage: build-singleuser [base image] [destination image]" >&2
exit 1
fi
echo "building $name from $base"
singleuser=dockerspawner/singleuser
# copy single-user stack
sed -i "s@^FROM.*\$@FROM $base@" "$singleuser/Dockerfile"
docker build -t "$name" "$singleuser"
echo "built $name"
...@@ -43,3 +43,13 @@ You may customize the execution of the Docker container and the Notebook server ...@@ -43,3 +43,13 @@ You may customize the execution of the Docker container and the Notebook server
## Conda Environment ## Conda Environment
The default Python 3.x [Conda environment](http://conda.pydata.org/docs/using/envs.html) resides in `/opt/conda`. The commands `ipython`, `python`, `pip`, `easy_install`, and `conda` (among others) are available in this environment. The default Python 3.x [Conda environment](http://conda.pydata.org/docs/using/envs.html) resides in `/opt/conda`. The commands `ipython`, `python`, `pip`, `easy_install`, and `conda` (among others) are available in this environment.
## JupyterHub
To use this stack with [JupyterHub](https://jupyterhub.readthedocs.org) and [DockerSpawner](https://github.com/jupyter/dockerspawner),
set
```python
c.DockerSpawner.container_image = 'jupyter/minimal-singleuser'
```
...@@ -132,3 +132,13 @@ source deactivate ...@@ -132,3 +132,13 @@ source deactivate
``` ```
The commands `ipython`, `python`, `pip`, `easy_install`, and `conda` (among others) are available in both environments. The commands `ipython`, `python`, `pip`, `easy_install`, and `conda` (among others) are available in both environments.
## JupyterHub
To use this stack with [JupyterHub](https://jupyterhub.readthedocs.org) and [DockerSpawner](https://github.com/jupyter/dockerspawner),
set
```python
c.DockerSpawner.container_image = 'jupyter/pyspark-singleuser'
```
...@@ -39,3 +39,13 @@ You may customize the execution of the Docker container and the Notebook server ...@@ -39,3 +39,13 @@ You may customize the execution of the Docker container and the Notebook server
* `-e GRANT_SUDO=yes` - Gives the `jovyan` user passwordless `sudo` capability. Useful for installing OS packages. For this option to take effect, you must run the container with `--user root`. (The `start-notebook.sh` script will `su jovyan` after adding `jovyan` to sudoers.) **You should only enable `sudo` if you trust the user or if the container is running on an isolated host.** * `-e GRANT_SUDO=yes` - Gives the `jovyan` user passwordless `sudo` capability. Useful for installing OS packages. For this option to take effect, you must run the container with `--user root`. (The `start-notebook.sh` script will `su jovyan` after adding `jovyan` to sudoers.) **You should only enable `sudo` if you trust the user or if the container is running on an isolated host.**
* `-v /some/host/folder/for/work:/home/jovyan/work` - Host mounts the default working directory on the host to preserve work even when the container is destroyed and recreated (e.g., during an upgrade). * `-v /some/host/folder/for/work:/home/jovyan/work` - Host mounts the default working directory on the host to preserve work even when the container is destroyed and recreated (e.g., during an upgrade).
* `-v /some/host/folder/for/server.pem:/home/jovyan/.local/share/jupyter/notebook.pem` - Mounts a SSL certificate plus key for `USE_HTTPS`. Useful if you have a real certificate for the domain under which you are running the Notebook server. * `-v /some/host/folder/for/server.pem:/home/jovyan/.local/share/jupyter/notebook.pem` - Mounts a SSL certificate plus key for `USE_HTTPS`. Useful if you have a real certificate for the domain under which you are running the Notebook server.
## JupyterHub
To use this stack with [JupyterHub](https://jupyterhub.readthedocs.org) and [DockerSpawner](https://github.com/jupyter/dockerspawner),
set
```python
c.DockerSpawner.container_image = 'jupyter/r-singleuser'
```
...@@ -55,3 +55,13 @@ source deactivate ...@@ -55,3 +55,13 @@ source deactivate
``` ```
The commands `ipython`, `python`, `pip`, `easy_install`, and `conda` (among others) are available in both environments. The commands `ipython`, `python`, `pip`, `easy_install`, and `conda` (among others) are available in both environments.
## JupyterHub
To use this stack with [JupyterHub](https://jupyterhub.readthedocs.org) and [DockerSpawner](https://github.com/jupyter/dockerspawner),
set
```python
c.DockerSpawner.container_image = 'jupyter/scipy-singleuser'
```
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment