├── .dockerignore ├── setup.cfg ├── static ├── robots.txt ├── fetch.min.js ├── metricsgraphics.css └── metricsgraphics.min.js ├── requirements.txt ├── script ├── bootstrap ├── initialize ├── dev ├── templates │ ├── orchestrate.conf │ └── config-proxy.conf ├── ubuntu-base ├── install └── cloud │ └── examples │ ├── coreos-single.yml │ └── coreos-onmetal-io1.yml ├── MANIFEST.in ├── Dockerfile-alpine3.5 ├── templates ├── ga.html ├── error │ ├── 404.html │ └── 500.html ├── full.html ├── loading.html └── stats.html ├── Dockerfile ├── setup.py ├── .gitignore ├── LICENSE ├── Makefile ├── docs └── operations.md ├── dockworker.py ├── README.md ├── orchestrate.py └── spawnpool.py /.dockerignore: -------------------------------------------------------------------------------- 1 | .git 2 | 3 | -------------------------------------------------------------------------------- /setup.cfg: -------------------------------------------------------------------------------- 1 | [bdist_wheel] 2 | universal=1 3 | -------------------------------------------------------------------------------- /static/robots.txt: -------------------------------------------------------------------------------- 1 | User-agent: * 2 | Disallow: /user/ 3 | Disallow: /spawn/ 4 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | tornado==4.3.0 2 | docker-py==1.7.2 3 | pycurl==7.43.0 4 | futures==3.0.5 5 | pytz==2015.7 6 | -------------------------------------------------------------------------------- /script/bootstrap: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -euo pipefail 4 | 5 | script/ubuntu-base 6 | script/install 7 | script/initialize 8 | -------------------------------------------------------------------------------- /script/initialize: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -euo pipefail 3 | 4 | # Initialize supervisor 5 | supervisorctl update 6 | 7 | # Go time! 8 | supervisorctl start all 9 | -------------------------------------------------------------------------------- /script/dev: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | export CONFIGPROXY_AUTH_TOKEN=`head -c 30 /dev/urandom | xxd -p` 3 | node_modules/.bin/configurable-http-proxy --default-target=http://127.0.0.1:9999 & 4 | python orchestrate.py $@ 5 | kill %% 6 | -------------------------------------------------------------------------------- /MANIFEST.in: -------------------------------------------------------------------------------- 1 | include requirements.txt 2 | include *.py 3 | include Makefile 4 | recursive-include static *.css *.js *.txt 5 | recursive-include templates *.html 6 | recursive-include script * 7 | include *.in 8 | include *.md 9 | include Dockerfile 10 | include LICENSE 11 | -------------------------------------------------------------------------------- /script/templates/orchestrate.conf: -------------------------------------------------------------------------------- 1 | [program:orchestrate] 2 | command=python %TMPNBPATH%/orchestrate.py 3 | autostart=true 4 | autorestart=true 5 | stderr_logfile=/var/log/orchestrate.err.log 6 | stdout_logfile=/var/log/orchestrate.out.log 7 | environment=CONFIGPROXY_AUTH_TOKEN=%TOKEN%,CONFIGPROXY_ENDPOINT=http://127.0.0.1:8001 8 | -------------------------------------------------------------------------------- /script/ubuntu-base: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -euo pipefail 4 | 5 | export DEBIAN_FRONTEND=noninteractive 6 | sudo apt-get update && apt-get upgrade -y 7 | sudo apt-get install -y nodejs-legacy build-essential curl python-pip python-dev supervisor npm libcurl4-openssl-dev 8 | curl -sSL https://get.docker.io/ubuntu/ | sudo sh 9 | -------------------------------------------------------------------------------- /script/templates/config-proxy.conf: -------------------------------------------------------------------------------- 1 | [program:config-proxy] 2 | command=%TMPNBPATH%/node_modules/.bin/configurable-http-proxy --default-target=http://127.0.0.1:9999 --port=8000 3 | autostart=true 4 | autorestart=true 5 | stderr_logfile=/var/log/config-proxy.err.log 6 | stdout_logfile=/var/log/config-proxy.out.log 7 | environment=CONFIGPROXY_AUTH_TOKEN=%TOKEN% 8 | user=nobody 9 | -------------------------------------------------------------------------------- /Dockerfile-alpine3.5: -------------------------------------------------------------------------------- 1 | FROM alpine:3.5 2 | 3 | RUN apk update && apk add python3 py3-curl py3-tz py3-tornado \ 4 | && pip3 install docker-py==1.7.2 \ 5 | && pip3 install --upgrade pip \ 6 | && rm -fr /root/.cache/pip && rm /var/cache/apk/* \ 7 | && ln -s /usr/bin/python3 /usr/bin/python \ 8 | && mkdir -p /srv/tmpnb 9 | 10 | WORKDIR /srv/tmpnb/ 11 | 12 | COPY . /srv/tmpnb/ 13 | 14 | ENV DOCKER_HOST unix://docker.sock 15 | 16 | CMD python orchestrate.py 17 | -------------------------------------------------------------------------------- /templates/ga.html: -------------------------------------------------------------------------------- 1 | 11 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM python:3.4-wheezy 2 | 3 | RUN apt-get update && apt-get install python-dev libcurl4-openssl-dev -y 4 | RUN pip install --upgrade pip 5 | 6 | RUN mkdir -p /srv/tmpnb 7 | WORKDIR /srv/tmpnb/ 8 | 9 | # Copy the requirements.txt in by itself first to avoid docker cache busting 10 | # any time any file in the project changes 11 | COPY requirements.txt /srv/tmpnb/requirements.txt 12 | RUN pip install -r requirements.txt 13 | 14 | # Now copy in everything else 15 | COPY . /srv/tmpnb/ 16 | 17 | ENV DOCKER_HOST unix://docker.sock 18 | 19 | CMD python orchestrate.py 20 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | from distutils.core import setup 2 | import sys 3 | 4 | if "develop" in sys.argv or any(arg.startswith("bdist") for arg in sys.argv): 5 | import setuptools 6 | 7 | setup_args = dict( 8 | name="tmpnb", 9 | version="0.1.0", 10 | description="Tool for launching temporary Jupyter notebook servers", 11 | url="https://github.com/jupyter/tmpnb", 12 | license="BSD", 13 | author="Jupyter Development Team", 14 | author_email="jupyter@googlegroups.com", 15 | platforms="Linux, Mac OS X" 16 | ) 17 | 18 | with open("requirements.txt") as required: 19 | setup_args["install_requires"] = required.read().splitlines() 20 | 21 | if __name__ == "__main__": 22 | setup(**setup_args) 23 | -------------------------------------------------------------------------------- /script/install: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -euo pipefail 4 | 5 | pip install -r requirements.txt 6 | npm install jupyter/configurable-http-proxy 7 | docker pull jupyter/demo 8 | 9 | # Link straight from where we cloned this 10 | TMPNBPATH=`pwd` 11 | 12 | # Make sure "nobody" can run the configurable-http-proxy 13 | chmod a+rX . -R 14 | chmod a+x node_modules/configurable-http-proxy/bin/configurable-http-proxy 15 | 16 | # Generate a random token for this node 17 | export TOKEN=$( head -c 30 /dev/urandom | xxd -p ) 18 | echo "Your TOKEN for the configurable-http-proxy is $TOKEN" 19 | 20 | # Create supervisor scripts 21 | for SCRIPT in `ls script/templates`; do 22 | sed -e "s;%TOKEN%;$TOKEN;g" -e "s;%TMPNBPATH%;$TMPNBPATH;g" script/templates/$SCRIPT > /etc/supervisor/conf.d/$SCRIPT 23 | done 24 | -------------------------------------------------------------------------------- /templates/error/404.html: -------------------------------------------------------------------------------- 1 | 2 |
3 |14 | It looks like we're full up. Every single IPython Notebook is in use right now! Try again later 15 | and maybe you'll have better luck. Sorry for the inconvenience! 16 |
17 |18 | If you hang around here for a while, you'll automatically retry in {{ cull_period }} 19 | seconds. 20 |
21 |The server you requested is no longer running or it doesn't exist.
21 | {% end %} 22 |Starting a new notebook server, just for you...
23 |