unsloth/docker/supervisord.conf
Daniel Han 08f9b67f60 docker: optional Cloudflare tunnel for JupyterLab (UNSLOTH_JUPYTER_CLOUDFLARE)
Mirror the public-link convenience Studio already has for its own UI, for
JupyterLab. Off by default; opt in two ways:

  docker run -e UNSLOTH_JUPYTER_CLOUDFLARE=1 ... unsloth/unsloth
  docker exec <container> unsloth-jupyter-tunnel --force

unsloth-jupyter-tunnel waits for JupyterLab, reuses a cached cloudflared (or
fetches the static binary for the arch, no account needed), and starts a
quick tunnel to the Jupyter port; the https://<name>.trycloudflare.com URL is
printed to docker logs. supervisord runs it as the jupyter-cloudflare program,
autostarted only when UNSLOTH_JUPYTER_CLOUDFLARE=1 (studio_launch.sh exports a
0 default so the autostart gate expands, matching the sshd pattern). JupyterLab
still enforces its password, so the tunnel is not an open door.

Verified: the helper fetches cloudflared and mints a working trycloudflare URL
that reaches JupyterLab (HTTP 200) inside a running container.
2026-06-24 09:55:11 +00:00

78 lines
2.3 KiB
Text

# Service manager for the full Unsloth image (Dockerfile.studio).
#
# Mirrors the service set of the production docker.io/unsloth/unsloth image:
# studio Unsloth Studio web UI port 8000
# jupyter JupyterLab for the notebooks port $JUPYTER_PORT (default 8888)
# sshd key-only SSH for cloud hosts port 22
#
# All three log to the container's stdout/stderr (the Docker-native pattern)
# so `docker logs` shows everything, including Studio's first-boot password
# and Jupyter's startup line.
[unix_http_server]
file=/run/supervisor.sock
chmod=0700
[supervisorctl]
serverurl=unix:///run/supervisor.sock
[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
[supervisord]
nodaemon=true
pidfile=/run/supervisord.pid
logfile=/dev/null
logfile_maxbytes=0
loglevel=info
[program:studio]
command=%(ENV_UNSLOTH_STUDIO_HOME)s/bin/unsloth studio -H 0.0.0.0 -p 8000
directory=/workspace
autostart=true
autorestart=true
startretries=3
startsecs=5
environment=HOME="/root",USER="root"
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
[program:jupyter]
command=jupyter lab --no-browser --ip=0.0.0.0 --port=%(ENV_JUPYTER_PORT)s --allow-root --notebook-dir=/workspace
directory=/workspace
autostart=true
autorestart=true
; HOME pins the config lookup to /root/.jupyter, where the launcher wrote
; the password config; without it an unset HOME would silently fall back
; to token auth.
environment=HOME="/root",USER="root"
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
; Optional public Cloudflare quick-tunnel for JupyterLab. Started only when
; UNSLOTH_JUPYTER_CLOUDFLARE=1 (studio_launch.sh exports a 0 default so this
; expands). The trycloudflare URL is printed to docker logs by cloudflared.
[program:jupyter-cloudflare]
command=/usr/local/bin/unsloth-jupyter-tunnel
directory=/workspace
autostart=%(ENV_UNSLOTH_JUPYTER_CLOUDFLARE)s
autorestart=true
startsecs=5
environment=HOME="/root",USER="root"
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
[program:sshd]
command=/usr/sbin/sshd -D -e
autostart=%(ENV_UNSLOTH_ENABLE_SSHD)s
autorestart=true
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0