Spaces:
Runtime error
Runtime error
Upload 4 files
Browse files- .dockerignore +2 -0
- Dockerfile.jupyterhub +12 -0
- docker-compose.yml +44 -0
- jupyterhub_config.py +61 -0
.dockerignore
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
tests/
|
| 2 |
+
docker-compose.yaml
|
Dockerfile.jupyterhub
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright (c) Jupyter Development Team.
|
| 2 |
+
# Distributed under the terms of the Modified BSD License.
|
| 3 |
+
ARG JUPYTERHUB_VERSION
|
| 4 |
+
FROM quay.io/jupyterhub/jupyterhub:$JUPYTERHUB_VERSION
|
| 5 |
+
|
| 6 |
+
# Install dockerspawner, nativeauthenticator
|
| 7 |
+
# hadolint ignore=DL3013
|
| 8 |
+
RUN python3 -m pip install --no-cache-dir \
|
| 9 |
+
dockerspawner \
|
| 10 |
+
jupyterhub-nativeauthenticator
|
| 11 |
+
|
| 12 |
+
CMD ["jupyterhub", "-f", "/srv/jupyterhub/jupyterhub_config.py"]
|
docker-compose.yml
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright (c) Jupyter Development Team.
|
| 2 |
+
# Distributed under the terms of the Modified BSD License.
|
| 3 |
+
|
| 4 |
+
# JupyterHub docker compose configuration file
|
| 5 |
+
version: "3"
|
| 6 |
+
|
| 7 |
+
services:
|
| 8 |
+
hub:
|
| 9 |
+
build:
|
| 10 |
+
context: .
|
| 11 |
+
dockerfile: Dockerfile.jupyterhub
|
| 12 |
+
args:
|
| 13 |
+
JUPYTERHUB_VERSION: latest
|
| 14 |
+
restart: always
|
| 15 |
+
image: jupyterhub
|
| 16 |
+
container_name: jupyterhub
|
| 17 |
+
networks:
|
| 18 |
+
- jupyterhub-network
|
| 19 |
+
volumes:
|
| 20 |
+
# The JupyterHub configuration file
|
| 21 |
+
- "./jupyterhub_config.py:/srv/jupyterhub/jupyterhub_config.py:ro"
|
| 22 |
+
# Bind Docker socket on the host so we can connect to the daemon from
|
| 23 |
+
# within the container
|
| 24 |
+
- "/var/run/docker.sock:/var/run/docker.sock:rw"
|
| 25 |
+
# Bind Docker volume on host for JupyterHub database and cookie secrets
|
| 26 |
+
- "jupyterhub-data:/data"
|
| 27 |
+
ports:
|
| 28 |
+
- "8000:8000"
|
| 29 |
+
environment:
|
| 30 |
+
# This username will be a JupyterHub admin
|
| 31 |
+
JUPYTERHUB_ADMIN: admin
|
| 32 |
+
# All containers will join this network
|
| 33 |
+
DOCKER_NETWORK_NAME: jupyterhub-network
|
| 34 |
+
# JupyterHub will spawn this Notebook image for users
|
| 35 |
+
DOCKER_NOTEBOOK_IMAGE: quay.io/jupyter/base-notebook:latest
|
| 36 |
+
# Notebook directory inside user image
|
| 37 |
+
DOCKER_NOTEBOOK_DIR: /home/jovyan/work
|
| 38 |
+
|
| 39 |
+
volumes:
|
| 40 |
+
jupyterhub-data:
|
| 41 |
+
|
| 42 |
+
networks:
|
| 43 |
+
jupyterhub-network:
|
| 44 |
+
name: jupyterhub-network
|
jupyterhub_config.py
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright (c) Jupyter Development Team.
|
| 2 |
+
# Distributed under the terms of the Modified BSD License.
|
| 3 |
+
|
| 4 |
+
# Configuration file for JupyterHub
|
| 5 |
+
import os
|
| 6 |
+
|
| 7 |
+
c = get_config() # noqa: F821
|
| 8 |
+
|
| 9 |
+
# We rely on environment variables to configure JupyterHub so that we
|
| 10 |
+
# avoid having to rebuild the JupyterHub container every time we change a
|
| 11 |
+
# configuration parameter.
|
| 12 |
+
|
| 13 |
+
# Spawn single-user servers as Docker containers
|
| 14 |
+
c.JupyterHub.spawner_class = "dockerspawner.DockerSpawner"
|
| 15 |
+
|
| 16 |
+
# Spawn containers from this image
|
| 17 |
+
c.DockerSpawner.image = os.environ["DOCKER_NOTEBOOK_IMAGE"]
|
| 18 |
+
|
| 19 |
+
# Connect containers to this Docker network
|
| 20 |
+
network_name = os.environ["DOCKER_NETWORK_NAME"]
|
| 21 |
+
c.DockerSpawner.use_internal_ip = True
|
| 22 |
+
c.DockerSpawner.network_name = network_name
|
| 23 |
+
|
| 24 |
+
# Explicitly set notebook directory because we'll be mounting a volume to it.
|
| 25 |
+
# Most `jupyter/docker-stacks` *-notebook images run the Notebook server as
|
| 26 |
+
# user `jovyan`, and set the notebook directory to `/home/jovyan/work`.
|
| 27 |
+
# We follow the same convention.
|
| 28 |
+
notebook_dir = os.environ.get("DOCKER_NOTEBOOK_DIR", "/home/jovyan/work")
|
| 29 |
+
c.DockerSpawner.notebook_dir = notebook_dir
|
| 30 |
+
|
| 31 |
+
# Mount the real user's Docker volume on the host to the notebook user's
|
| 32 |
+
# notebook directory in the container
|
| 33 |
+
c.DockerSpawner.volumes = {"jupyterhub-user-{username}": notebook_dir}
|
| 34 |
+
|
| 35 |
+
# Remove containers once they are stopped
|
| 36 |
+
c.DockerSpawner.remove = True
|
| 37 |
+
|
| 38 |
+
# For debugging arguments passed to spawned containers
|
| 39 |
+
c.DockerSpawner.debug = True
|
| 40 |
+
|
| 41 |
+
# User containers will access hub by container name on the Docker network
|
| 42 |
+
c.JupyterHub.hub_ip = "jupyterhub"
|
| 43 |
+
c.JupyterHub.hub_port = 8080
|
| 44 |
+
|
| 45 |
+
# Persist hub data on volume mounted inside container
|
| 46 |
+
c.JupyterHub.cookie_secret_file = "/data/jupyterhub_cookie_secret"
|
| 47 |
+
c.JupyterHub.db_url = "sqlite:////data/jupyterhub.sqlite"
|
| 48 |
+
|
| 49 |
+
# Allow all signed-up users to login
|
| 50 |
+
c.Authenticator.allow_all = True
|
| 51 |
+
|
| 52 |
+
# Authenticate users with Native Authenticator
|
| 53 |
+
c.JupyterHub.authenticator_class = "nativeauthenticator.NativeAuthenticator"
|
| 54 |
+
|
| 55 |
+
# Allow anyone to sign-up without approval
|
| 56 |
+
c.NativeAuthenticator.open_signup = True
|
| 57 |
+
|
| 58 |
+
# Allowed admins
|
| 59 |
+
admin = os.environ.get("JUPYTERHUB_ADMIN")
|
| 60 |
+
if admin:
|
| 61 |
+
c.Authenticator.admin_users = [admin]
|