-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #40 from yambottle/DEV-530
- Loading branch information
Showing
5 changed files
with
80 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,68 @@ | ||
TODO - will make this a proper README.md later | ||
|
||
Pro | ||
- Break the chain of dependencies of self-managed base images | ||
- Reduce image maintenance hell | ||
- Use jupyter/minimal-notebook as base image instead | ||
- Compatible with previous supported feature as many as possible | ||
- Provide simpler way for mainteners to manage system dependencies and for users to install packages | ||
- Provide a way to config jupyter through environment variables | ||
- This can be used as jupyter lab, so we can archive djlab-docker and only focus on this repo | ||
- Add jupyterhub docker for single user image testing at local | ||
|
||
Con | ||
- Username if jovyan by default, consider this is a minor issue, since it's only visible in the terminal | ||
- Larger image size, this can be optimized when it becomes a problem | ||
# djlabhub-docker | ||
|
||
## Table of Contents | ||
- [Introduction](#introduction) | ||
- [Quick Start](#quick-start) | ||
- [Build Jupyterhub Singleuser Image](#build-jupyterhub-singleuser-image) | ||
- [Configuration](#configuration) | ||
- [Build](#build) | ||
- [Test in Local Jupyterhub](#test-in-local-jupyterhub) | ||
- [Local Jupyterhub Configuration](#local-jupyterhub-configuration) | ||
- [Start Local Jupyterhub](#start-local-jupyterhub) | ||
|
||
## Introduction | ||
|
||
This image is made for building customized jupyterhub profile/server option images. It was originally based on [datajoint/djlab](https://github.com/datajoint/djlab-docker) all the way up to [datajoint/djbase](https://github.com/datajoint/djbase-docker). To reduce the maintenance effort, we decided to use quay.io/jupyter/minimal-notebook as the base image. We also kept the previous implementation under `legacy` directory, just in case there are unforeseen issues with the new implementation. | ||
|
||
> **Note**: `datajoint/djlab` is deprecated since the `singleuser` part of this image overlaps with the `djlab` image, it'll run jupyter lab server by default. | ||
|
||
## Quick Start | ||
Directory explain: | ||
- `~/legacy` contains the old implementation of the image | ||
- `~/singleuser` is used to build the jupyterhub profile images | ||
- `~/hub` is a Docker based jupyterhub host server using DockerSpawner and Docker-in-Docker to launch jupyterhub singleuser server as a Docker container, in order to locally validate the singleuser images for development purpose.(**Don't recommend to use this in production, due to the security concern of Docker-in-Docker**) | ||
|
||
|
||
## Build Jupyterhub Singleuser Image | ||
|
||
### Configuration | ||
We put all the dependencies in the `~/singleuser/config` directory including: | ||
- `apt_install.sh` for system level dependencies | ||
- `pip_requirements.txt` for python packages | ||
- `before_start_hook.sh` to run before the jupyterhub singleuser server starts, [doc](https://jupyter-docker-stacks.readthedocs.io/en/latest/using/common.html#startup-hooks) | ||
- `jupyter**config.py` for jupyter related configurations | ||
- Jupyter Server Config, [doc](https://jupyter-server.readthedocs.io/en/latest/other/full-config.html#other-full-config) | ||
- Jupyter Notebook Server Config, [doc](https://jupyter-notebook.readthedocs.io/en/5.7.4/config.html) | ||
- Jupyter Lab Server Config, [doc](https://jupyterlab-server.readthedocs.io/en/latest/api/app-config.html) | ||
- Optionally, you can add more configurations for ipython kernel, etc. | ||
> **Note**: We added `jupyter**config.py` to extract configurations from the environment variables for some that are not supported to set by environment variables directly. The goal is to make the jupyterhub profile list clear and easy to maintain. | ||
### Build | ||
``` | ||
# make the .env file from the example.env | ||
set -a && source .env && set +a | ||
docker compose build | ||
# To run this image as local jupyterlab server for testing | ||
# The default password is set by the `JUPYTER_SERVER_APP_PASSWORD` in the container | ||
docker compose up djlab | ||
``` | ||
|
||
### Test in Local Jupyterhub | ||
#### Local Jupyterhub Configuration | ||
Similarly to the singleuser image, we the `jupyterhub_config.py` in the `~/hub/config` directory, you need to modify the `c.DockerSpawner.container_image` and `c.DockerSpawner.environment` to configure your singleuser server container. | ||
|
||
#### Start Local Jupyterhub | ||
> **Note**: Local Jupyterhub requires jupyterhub host container to mount `/var/run/docker.sock:/var/run/docker.sock` to enable Docker-in-Docker, [doc](https://devopscube.com/run-docker-in-docker/) | ||
``` | ||
# make the .env file from the example.env | ||
# OAUTH2 related configurations are not necessary | ||
# since the c.JupyterHub.authenticator_class = "jupyterhub.auth.DummyAuthenticator" | ||
set -a && source .env && set +a | ||
# It takes any random username and password | ||
docker compose up | ||
``` | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters