Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev 221 djlabhub chain breaker #34

Merged
merged 16 commits into from
Mar 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions .github/workflows/singleuser-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: singleuser-relase-wip
on:
workflow_dispatch:
inputs:
jupyterhub_version:
required: true
default: '4.0.2'
type: choice
options:
- '4.0.2'
- '1.4.2'
jobs:
release-image:
runs-on: ubuntu-latest
strategy:
matrix:
include:
# following python version end of life: https://devguide.python.org/versions/
- py_ver: '3.10'
- py_ver: '3.9'
- py_ver: '3.8'
env:
PY_VER: ${{matrix.py_ver}}
JUPYTERHUB_VER: ${{github.event.inputs.jupyterhub_version}}
steps:
- uses: actions/checkout@v4
# TODO - use docker build action
# TODO - use conventional commit action to make release and changelog
ethho marked this conversation as resolved.
Show resolved Hide resolved
7 changes: 1 addition & 6 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1 @@
.vscode
*.tar.gz
docs/_build
sphinx-validator.yaml
common
home_user
.env
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
TODO - will make this a proper README.md later

Pro
- Break the chain of dependencies of self-managed base images
- Reduce image maintenance hell
ethho marked this conversation as resolved.
Show resolved Hide resolved
- 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
30 changes: 0 additions & 30 deletions config/.env

This file was deleted.

34 changes: 0 additions & 34 deletions dist/alpine/docker-compose.yaml

This file was deleted.

34 changes: 0 additions & 34 deletions dist/debian/docker-compose.yaml

This file was deleted.

5 changes: 5 additions & 0 deletions hub/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
ARG JUPYTERHUB_VERSION
FROM jupyterhub/jupyterhub:${JUPYTERHUB_VERSION}

COPY ./config/jupyterhub_config.py /etc/jupyterhub/jupyterhub_config.py
RUN pip install dockerspawner oauthenticator
97 changes: 97 additions & 0 deletions hub/config/jupyterhub_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
import os
import pwd
from traitlets.config import Config

c = Config() if "c" not in locals() else c

# get the current user
user = [u for u in pwd.getpwall() if u.pw_uid == os.getuid()][0]

## Class for authenticating users.
#
# This should be a subclass of :class:`jupyterhub.auth.Authenticator`
#
# with an :meth:`authenticate` method that:
#
# - is a coroutine (asyncio or tornado)
# - returns username on success, None on failure
# - takes two arguments: (handler, data),
# where `handler` is the calling web.RequestHandler,
# and `data` is the POST form data from the login page.
#
# .. versionchanged:: 1.0
# authenticators may be registered via entry points,
# e.g. `c.JupyterHub.authenticator_class = 'pam'`
#
# Currently installed:
# - default: jupyterhub.auth.PAMAuthenticator
# - dummy: jupyterhub.auth.DummyAuthenticator
# - null: jupyterhub.auth.NullAuthenticator
# - pam: jupyterhub.auth.PAMAuthenticator
# Default: 'jupyterhub.auth.PAMAuthenticator'
c.JupyterHub.authenticator_class = "jupyterhub.auth.DummyAuthenticator"

# ## TODO - callback_url needs to enable ssl
# c.JupyterHub.authenticator_class = "oauthenticator.generic.GenericOAuthenticator"
# c.GenericOAuthenticator.client_id = os.getenv("OAUTH2_CLIENT_ID")
# c.GenericOAuthenticator.client_secret = os.getenv("OAUTH2_CLIENT_SECRET")
# c.GenericOAuthenticator.oauth_callback_url = "https://127.0.0.1:8000/hub/oauth_callback"
# c.GenericOAuthenticator.authorize_url = "https://keycloak-qa.datajoint.io/realms/datajoint/protocol/openid-connect/auth"
# c.GenericOAuthenticator.token_url = "https://keycloak-qa.datajoint.io/realms/datajoint/protocol/openid-connect/token"
# c.GenericOAuthenticator.userdata_url = "https://keycloak-qa.datajoint.io/realms/datajoint/protocol/openid-connect/userinfo"
# c.GenericOAuthenticator.login_service = "Datajoint"
# c.GenericOAuthenticator.username_claim = "preferred_username"
# c.GenericOAuthenticator.enable_auth_state = True
# c.GenericOAuthenticator.scope = ["openid"]
# c.GenericOAuthenticator.claim_groups_key = "groups"
# c.GenericOAuthenticator.admin_groups = ["datajoint"]

## The class to use for spawning single-user servers.
#
# Should be a subclass of :class:`jupyterhub.spawner.Spawner`.
#
# .. versionchanged:: 1.0
# spawners may be registered via entry points,
# e.g. `c.JupyterHub.spawner_class = 'localprocess'`
#
# Currently installed:
# - default: jupyterhub.spawner.LocalProcessSpawner
# - localprocess: jupyterhub.spawner.LocalProcessSpawner
# - simple: jupyterhub.spawner.SimpleLocalProcessSpawner
# Default: 'jupyterhub.spawner.LocalProcessSpawner'
c.JupyterHub.spawner_class = "dockerspawner.DockerSpawner"

## The ip address for the Hub process to *bind* to.
#
# By default, the hub listens on localhost only. This address must be accessible from
# the proxy and user servers. You may need to set this to a public ip or '' for all
# interfaces if the proxy or user servers are in containers or on a different host.
#
# See `hub_connect_ip` for cases where the bind and connect address should differ,
# or `hub_bind_url` for setting the full bind URL.
# Default: '127.0.0.1'
c.JupyterHub.hub_ip = ""

c.DockerSpawner.network_name = os.getenv("DOCKER_NETWORK_NAME", "jupyterhub_network")
c.DockerSpawner.start_timeout = 60
# https://github.com/jupyterhub/jupyterhub/issues/2913#issuecomment-580535422
c.Spawner.http_timeout = 60
c.Spawner.start_timeout = 60
c.DockerSpawner.container_image = "datajoint/djlabhub:singleuser-4.0.2-py3.10-qa"

c.DockerSpawner.environment = {
## Jupyter Official Environment Variables
"DOCKER_STACKS_JUPYTER_CMD": "lab",
## Extended by Datajoint
## Before Start Hook
"DJLABHUB_REPO": "https://github.com/datajoint/datajoint-tutorials.git",
"DJLABHUB_REPO_BRANCH": "main",
"DJLABHUB_REPO_INSTALL": "TRUE",
## Jupyter Config
# "JUPYTER_SERVER_APP_IP": "0.0.0.0",
# "JUPYTER_SERVER_APP_PASSWORD": "",
# "JUPYTER_SERVER_APP_PORT": "8889",
# "JUPYTER_SERVER_APP_ROOT_DIR": "/home/jovyan",
"JUPYTER_FILE_CONTENTS_MANAGER_ROOT_DIR": "/home/jovyan",
"JUPYTER_YDOCEXTENSION_DISABLE_RTC": "TRUE",
}
29 changes: 29 additions & 0 deletions hub/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
version: '3.7'
services:
hub:
build:
context: .
dockerfile: Dockerfile
args:
- JUPYTERHUB_VERSION
image: datajoint/djlabhub:hub-${JUPYTERHUB_VERSION}
container_name: djlabhub-hub
user: root
env_file: .env
# network to connect the hub and singleusers
networks:
- jupyterhub_network
environment:
- DOCKER_NETWORK_NAME=jupyterhub_network
command: jupyterhub -f /etc/jupyterhub/jupyterhub_config.py
ports:
- 8000:8000
volumes:
- ./config/jupyterhub_config.py:/etc/jupyterhub/jupyterhub_config.py
- /var/run/docker.sock:/var/run/docker.sock

networks:
jupyterhub_network:
name: jupyterhub_network
driver: bridge

7 changes: 7 additions & 0 deletions hub/example.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# build
JUPYTERHUB_VERSION=4.0.2

OAUTH2_CLIENT_ID=
OAUTH2_CLIENT_SECRET=
# Need to generate by `openssl rand -hex 32`
JUPYTERHUB_CRYPT_KEY=
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
name: Development
on:
push:
pull_request:
# push:
# pull_request:
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
Expand Down
6 changes: 6 additions & 0 deletions legacy/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.vscode
*.tar.gz
docs/_build
sphinx-validator.yaml
common
home_user
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading