feat(auth): support subscription login alongside API key
Make ANTHROPIC_API_KEY optional. Add CLAUDE_CODE_OAUTH_TOKEN pass-through for headless token-based auth (claude setup-token). When neither is set, Claude Code falls back to browser OAuth on port 54545. Add claude-config named volume mounted at ~/.claude/ in both claude and webui services so credentials persist across container runs. Pre-create ~/.claude/ in the Dockerfile so the volume is initialised with correct ownership. Add --service-ports to docker compose run calls to publish port 54545 during CLI sessions.
This commit is contained in:
parent
88805a3c24
commit
ba3730a24d
6 changed files with 90 additions and 19 deletions
17
claude.sh
Executable file → Normal file
17
claude.sh
Executable file → Normal file
|
|
@ -32,10 +32,13 @@ load_env() {
|
|||
# shellcheck disable=SC1090
|
||||
set -a; source "$env_file"; set +a
|
||||
fi
|
||||
if [[ -z "${ANTHROPIC_API_KEY:-}" ]]; then
|
||||
error "ANTHROPIC_API_KEY is not set."
|
||||
error "Copy .env.example → .env and add your key, or export it in your shell."
|
||||
exit 1
|
||||
if [[ -z "${ANTHROPIC_API_KEY:-}" && -z "${CLAUDE_CODE_OAUTH_TOKEN:-}" ]]; then
|
||||
warn "No ANTHROPIC_API_KEY or CLAUDE_CODE_OAUTH_TOKEN found."
|
||||
warn "Claude Code will prompt you to authenticate on first run."
|
||||
warn " Option 1 (API key): set ANTHROPIC_API_KEY in .env"
|
||||
warn " Option 2 (token): run 'claude setup-token' and set CLAUDE_CODE_OAUTH_TOKEN in .env"
|
||||
warn " Option 3 (browser): run './claude.sh run' and follow the login prompt;"
|
||||
warn " port 54545 must be reachable from your browser."
|
||||
fi
|
||||
}
|
||||
|
||||
|
|
@ -72,7 +75,7 @@ cmd_start() {
|
|||
dc up -d proxy # no-op if already healthy; compose waits via depends_on
|
||||
info "Launching Claude Code..."
|
||||
# shellcheck disable=SC2046
|
||||
dc run --rm $(workspace_flag) claude "$@"
|
||||
dc run --rm --service-ports $(workspace_flag) claude "$@"
|
||||
}
|
||||
|
||||
cmd_stop() {
|
||||
|
|
@ -89,7 +92,7 @@ cmd_run() {
|
|||
dc up -d proxy
|
||||
info "Launching Claude Code..."
|
||||
# shellcheck disable=SC2046
|
||||
dc run --rm $(workspace_flag) claude "$@"
|
||||
dc run --rm --service-ports $(workspace_flag) claude "$@"
|
||||
}
|
||||
|
||||
cmd_update() {
|
||||
|
|
@ -115,7 +118,7 @@ cmd_shell() {
|
|||
load_env
|
||||
warn "Opening debug shell inside Claude container (non-Claude entrypoint)."
|
||||
# shellcheck disable=SC2046
|
||||
dc run --rm --entrypoint /bin/bash $(workspace_flag) claude
|
||||
dc run --rm --service-ports --entrypoint /bin/bash $(workspace_flag) claude
|
||||
}
|
||||
|
||||
cmd_web() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue