Skip to content

fix(docker): bootstrap Claude auth for containerized phantom#47

Open
electronicBlacksmith wants to merge 1 commit intoghostwright:mainfrom
electronicBlacksmith:upstream/fix/docker-auth-bootstrap
Open

fix(docker): bootstrap Claude auth for containerized phantom#47
electronicBlacksmith wants to merge 1 commit intoghostwright:mainfrom
electronicBlacksmith:upstream/fix/docker-auth-bootstrap

Conversation

@electronicBlacksmith
Copy link
Copy Markdown

Summary

The Docker entrypoint never installed authentication credentials, so every container recreate booted without them and phantom responded with "please /login" to any Slack message.

Two auth paths added:

  1. Preferred: CLAUDE_CODE_OAUTH_TOKEN in .env, generated once via claude setup-token inside the container. Long-lived (1 year) token with its own session - never rotates, never conflicts with host CLI sessions.

  2. Fallback: docker-compose.override.yml can bind-mount the host's ~/.claude/.credentials.json. On boot, installs it with 600 perms and starts a background loop that re-copies when the host file changes.

Auth priority: token env var > credentials mount > neither (prints message that ANTHROPIC_API_KEY is expected).

Files changed

  • scripts/docker-entrypoint.sh - Auth bootstrap logic

Test plan

  • Container boots with CLAUDE_CODE_OAUTH_TOKEN and authenticates
  • Container boots with credentials mount and authenticates
  • Container boots with neither and prints guidance message

The entrypoint never installed authentication credentials, so every
container recreate booted without them and phantom responded with
"please /login" to any Slack message.

Two paths:

1. Preferred: CLAUDE_CODE_OAUTH_TOKEN in .env, generated once via
   `claude setup-token` inside the container. This is a long-lived
   (1 year) token with its own session, so it never rotates and
   will never conflict with a Claude Code session running on the
   host. Skips the credentials mount entirely.

2. Fallback: docker-compose.override.yml can bind-mount the host's
   ~/.claude/.credentials.json to /tmp/.credentials-mount.json.
   On boot we install it into /home/phantom/.claude/ with 600 perms
   and start a background loop that re-copies when the host file
   changes, so host-side token refreshes propagate without a
   restart.

   WARNING in the entrypoint comment: this path shares a rotating
   OAuth session between the host and the container, which the auth
   backend rejects as concurrent use and which will eventually cause
   the CLI to delete its own credentials to force re-login. Only
   safe when nothing else on the host is running Claude Code.

Auth priority is token env var > credentials mount > neither (the
latter prints a message that ANTHROPIC_API_KEY is expected).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant