Commit db33c10f authored by Min RK's avatar Min RK

build JupyterHub singleuser images for each stack

For every `*-notebook` stack, a `*-singleuser` image is also built
parent 2b575ad6
......@@ -61,3 +61,5 @@ target/
# Mac OS X
.DS_Store
dockerspawner
\ No newline at end of file
......@@ -12,6 +12,11 @@ ALL_STACKS:=minimal-kernel \
datascience-notebook \
pyspark-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)
help:
......@@ -27,7 +32,10 @@ build/%: DARGS?=
build/%:
docker build $(DARGS) --rm --force-rm -t $(OWNER)/$(notdir $@):latest ./$(notdir $@)
build-all: $(patsubst %,build/%, $(ALL_STACKS))
build/%-singleuser: build/%-notebook
./internal/build-singleuser $(OWNER)/$*-notebook $(OWNER)/$*-singleuser
build-all: $(patsubst %,build/%, $(ALL_IMAGES))
dev/%: ARGS?=
dev/%: DARGS?=
......@@ -42,18 +50,18 @@ push/%:
docker push $(OWNER)/$(notdir $@):latest
docker push $(OWNER)/$(notdir $@):$(GIT_MASTER_HEAD_SHA)
push-all: $(patsubst %,push/%, $(ALL_IMAGES))
refresh/%:
# skip if error: a stack might not be on dockerhub yet
-docker pull $(OWNER)/$(notdir $@):latest
refresh-all: $(patsubst %,refresh/%, $(ALL_STACKS))
refresh-all: $(patsubst %,refresh/%, $(ALL_IMAGES))
release-all: environment-check \
$(patsubst %,refresh/%, $(ALL_STACKS)) \
$(patsubst %,build/%, $(ALL_STACKS)) \
$(patsubst %,tag/%, $(ALL_STACKS)) \
$(patsubst %,push/%, $(ALL_STACKS))
release-all: environment-check refresh-all build-all tag-all push-all
tag/%:
# always tag the latest build with the git sha
docker tag -f $(OWNER)/$(notdir $@):latest $(OWNER)/$(notdir $@):$(GIT_MASTER_HEAD_SHA)
tag-all: $(patsubst %,tag/%, $(ALL_IMAGES))
#!/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
# get dockerspawner
if [[ ! -d dockerspawner ]]; then
git clone https://github.com/jupyter/dockerspawner
else
cd dockerspawner
git pull
cd -
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"
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