Files
docker-jupyterhub/jupyterhub_config.py.bak
2024-05-25 11:18:16 +08:00

69 lines
2.4 KiB
Python
Executable File
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import os
from pathlib import Path
from dockerspawner import DockerSpawner
c = get_config()
c.Application.log_level = 'DEBUG'
# 基本的JupyterHub配置
c.JupyterHub.cookie_secret_file = os.path.expanduser('~/.jupyterhub/jupyterhub_cookie_secret')
db_file = os.path.expanduser('~/.jupyterhub/jupyterhub.sqlite')
c.JupyterHub.db_url = f'sqlite:///{db_file}'
c.ConfigurableHTTPProxy.pid_file = os.path.expanduser('~/.jupyterhub/jupyterhub-proxy.pid')
# Authenticator 设置
c.JupyterHub.authenticator_class = 'jupyterhub.auth.PAMAuthenticator'
c.PAMAuthenticator.encoding = 'utf8'
c.Authenticator.admin_users = set()
c.Authenticator.allowed_users = set()
c.LocalAuthenticator.create_system_users = True
# Spawner 设置
c.Spawner.ip = '127.0.0.1'
c.Spawner.cmd = ['jupyter-labhub']
c.Spawner.default_url = '/lab'
c.LocalProcessSpawner.shell_cmd = ["bash", "-l", "-c"]
c.Spawner.notebook_dir = '~'
c.Spawner.args = ['--allow-root', "--KernelSpecManager.ensure_native_kernel=False", '--NotebookApp.allow_origin_pat=https://.*vscode-cdn\\.net', '--NotebookApp.iopub_data_rate_limit=10000000']
# 环境变量保持
c.Spawner.env_keep = ['PATH', 'PYTHONPATH', 'LD_LIBRARY_PATH', 'ENV1', 'ENV2']
# JupyterHub 服务配置
c.JupyterHub.ip = '0.0.0.0'
c.JupyterHub.port = 9000
c.JupyterHub.shutdown_on_logout = True
c.JupyterHub.statsd_prefix = 'jupyterhub'
c.JupyterHub.page_title = 'JupyterHub Service'
# Dockerspawner 配置(如果需要启用)
c.JupyterHub.spawner_class = DockerSpawner
c.DockerSpawner.allowed_images='*'
# Docker 守护进程的地址
c.DockerSpawner.docker_host = 'unix:///var/run/docker.sock'
# 使用的 Docker 镜像
c.DockerSpawner.image = 'quay.io/jupyter/scipy-notebook'
# 删除容器当它停止时
c.DockerSpawner.remove = True
# 设置网络(如果您有特定的 Docker 网络配置)
# c.DockerSpawner.network_name = 'jupyterhub'
# JupyterHub 的连接地址,用于 DockerSpawner 内部通信
# 如果 JupyterHub 运行在同一 Docker 网络中,可以使用 Docker 容器名称
# c.JupyterHub.hub_connect_ip = 'jupyterhub'
# 其他配置...
# 注意:下面这行配置是不必要的,因为您已经使用 Unix 套接字
# c.DockerSpawner.docker_host = 'tcp://docker-daemon-host:2375'
# 如果使用TLS根据需要取消注释
# os.environ['DOCKER_TLS_VERIFY'] = '1'
# os.environ['DOCKER_CERT_PATH'] = '/path/to/certificates'
# 其他配置(根据需要添加)
# ...