feat(webui): add browser terminal interface via ttyd
Adds a webui service to docker-compose that wraps Claude Code in ttyd, serving a browser-accessible terminal on port 7681. The webui reuses Dockerfile.claude (ttyd added to apt deps) with a dedicated entrypoint script that enforces WEBUI_PASSWORD before starting. Network isolation is identical to the CLI container: claude-internal only, all egress via the proxy allowlist. claude.sh gains web and web-stop commands.
This commit is contained in:
parent
c01102b641
commit
9b8562b746
7 changed files with 209 additions and 92 deletions
71
claude.sh
71
claude.sh
|
|
@ -118,43 +118,76 @@ cmd_shell() {
|
|||
dc run --rm --entrypoint /bin/bash $(workspace_flag) claude
|
||||
}
|
||||
|
||||
cmd_web() {
|
||||
check_deps
|
||||
load_env
|
||||
if [[ -z "${WEBUI_PASSWORD:-}" ]]; then
|
||||
error "WEBUI_PASSWORD is not set. Add it to .env before starting the web interface."
|
||||
exit 1
|
||||
fi
|
||||
info "Building images..."
|
||||
dc build
|
||||
info "Starting proxy and web interface..."
|
||||
dc up -d webui
|
||||
local port=7681
|
||||
info "Web interface is up → http://0.0.0.0:${port}"
|
||||
info "Credentials: ${WEBUI_USER:-claude} / [WEBUI_PASSWORD]"
|
||||
warn "To reach it from outside this host, publish the port:"
|
||||
warn " sbx ports <sandbox-name> --publish ${port}:${port}/tcp"
|
||||
}
|
||||
|
||||
cmd_web_stop() {
|
||||
check_deps
|
||||
info "Stopping web interface..."
|
||||
dc stop webui
|
||||
dc rm -f webui
|
||||
}
|
||||
|
||||
cmd_help() {
|
||||
cat <<EOF
|
||||
Usage: $(basename "$0") <command> [args]
|
||||
|
||||
Commands:
|
||||
start [args] Build images, start proxy, launch Claude Code
|
||||
run [args] Start proxy if needed, launch Claude Code
|
||||
stop Stop and remove all containers
|
||||
update Rebuild images without cache
|
||||
logs [svc] Tail logs (default: proxy)
|
||||
status Show container status
|
||||
shell Open a bash shell in the Claude container (debug)
|
||||
help Show this message
|
||||
start [args] Build images, start proxy, launch Claude Code (CLI)
|
||||
run [args] Start proxy if needed, launch Claude Code (CLI)
|
||||
web Build images, start proxy + web interface (browser terminal)
|
||||
web-stop Stop the web interface (keeps proxy running)
|
||||
stop Stop and remove all containers
|
||||
update Rebuild images without cache
|
||||
logs [svc] Tail logs (default: proxy)
|
||||
status Show container status
|
||||
shell Open a bash shell in the Claude container (debug)
|
||||
help Show this message
|
||||
|
||||
Environment variables:
|
||||
ANTHROPIC_API_KEY Required. Set in .env or exported in your shell.
|
||||
WORKSPACE_DIR Optional. Absolute path to mount as /workspace.
|
||||
Environment variables (set in .env or shell):
|
||||
ANTHROPIC_API_KEY Required for all modes.
|
||||
WORKSPACE_DIR Optional (CLI mode). Host path to mount as /workspace.
|
||||
Defaults to a named Docker volume (fully isolated).
|
||||
WEBUI_USER Web interface username (default: claude).
|
||||
WEBUI_PASSWORD Required for web mode. Basic auth password.
|
||||
|
||||
Examples:
|
||||
./claude.sh start
|
||||
WORKSPACE_DIR=\$HOME/myproject ./claude.sh run
|
||||
./claude.sh web
|
||||
./claude.sh logs proxy
|
||||
./claude.sh logs webui
|
||||
./claude.sh shell
|
||||
EOF
|
||||
}
|
||||
|
||||
# ─── Dispatch ─────────────────────────────────────────────────────────────────
|
||||
case "${1:-help}" in
|
||||
start) shift; cmd_start "$@" ;;
|
||||
stop) cmd_stop ;;
|
||||
run) shift; cmd_run "$@" ;;
|
||||
update) cmd_update ;;
|
||||
logs) shift; cmd_logs "${1:-}" ;;
|
||||
status) cmd_status ;;
|
||||
shell) cmd_shell ;;
|
||||
help|-h|--help) cmd_help ;;
|
||||
start) shift; cmd_start "$@" ;;
|
||||
stop) cmd_stop ;;
|
||||
run) shift; cmd_run "$@" ;;
|
||||
web) cmd_web ;;
|
||||
web-stop) cmd_web_stop ;;
|
||||
update) cmd_update ;;
|
||||
logs) shift; cmd_logs "${1:-}" ;;
|
||||
status) cmd_status ;;
|
||||
shell) cmd_shell ;;
|
||||
help|-h|--help) cmd_help ;;
|
||||
*)
|
||||
error "Unknown command: ${1}"
|
||||
cmd_help
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue