Skip to content

Commit 1ee3530

Browse files
committed
refactor(claude-code): update configuration for OAuth login and remove API key options
1 parent 5ed4d14 commit 1ee3530

3 files changed

Lines changed: 37 additions & 30 deletions

File tree

services/claude-code/.env.example

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,6 @@
44
# Project settings
55
COMPOSE_PROJECT_NAME=claude-code
66

7-
# Authentication (use ONE of these)
8-
# Option 1: API key (charges API account, good for automation)
9-
ANTHROPIC_API_KEY=sk-ant-api03-xxxxxxxxxxxxxxxxxxxxxxxxxxxx
10-
# Option 2: OAuth token for Claude Pro/Max subscription (no per-request charges)
11-
# Generate once with: claude setup-token
12-
# CLAUDE_CODE_OAUTH_TOKEN=clt-oauth-xxxxxxxxxxxxxxxxxxxxxxxxx
13-
147
# Git repository (SSH URL for deploy key auth)
158
# GIT_REPO=git@github.com:your-org/your-repo.git
169
# GIT_BRANCH=main

services/claude-code/README.md

Lines changed: 34 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -51,24 +51,40 @@ docker compose logs -f
5151
docker compose down
5252
```
5353

54-
## Configuration
54+
## First Launch -- Interactive Login
5555

56-
### Authentication
56+
Remote control mode requires an OAuth login (API keys are **not** supported). On first launch, you must attach to the container and complete the login flow:
5757

58-
You need **one** of the following:
58+
1. **Start the container** (see Quick Start above).
5959

60-
| Variable | Description |
61-
|----------|-------------|
62-
| `ANTHROPIC_API_KEY` | Anthropic API key (charges API account) |
63-
| `CLAUDE_CODE_OAUTH_TOKEN` | OAuth token for Claude Pro/Max subscription |
60+
2. **Attach to the running container:**
61+
```bash
62+
docker attach claude-code
63+
```
6464

65-
**API Key** is recommended for automation. Get one from [console.anthropic.com](https://console.anthropic.com/).
65+
3. **Complete the OAuth login** -- the entrypoint will automatically run `claude login`. Follow the URL printed in the terminal to authenticate in your browser.
6666

67-
**OAuth Token** bills against your Claude subscription instead of API credits. Generate once on a trusted machine:
67+
4. **After login succeeds**, press `Ctrl+C` to continue. The entrypoint will then launch `claude remote-control`.
6868

69-
```bash
70-
claude setup-token
71-
```
69+
5. **Detach from the container** with `Ctrl+P` then `Ctrl+Q` (Docker's detach sequence). The container continues running in the background.
70+
71+
Subsequent container restarts will use the persisted credentials and skip the login step entirely.
72+
73+
## Credential Storage
74+
75+
Claude Code stores its credentials in these locations inside the container:
76+
77+
| Path | Purpose |
78+
|------|---------|
79+
| `/home/node/.claude/.credentials.json` | OAuth tokens (access + refresh) |
80+
| `/home/node/.claude.json` | Account metadata and onboarding state |
81+
| `/home/node/.claude/` | Full config directory (credentials, settings, history) |
82+
83+
To persist credentials across container restarts, a volume is mounted at `/home/node/.claude` (the `claude_config` volume in docker-compose.yml).
84+
85+
The image pre-seeds `/home/node/.claude.json` with onboarding state so Claude Code does not prompt for initial setup.
86+
87+
## Configuration
7288

7389
### Git Repository
7490

@@ -105,15 +121,15 @@ The deploy key is base64-encoded so it fits on a single line in the `.env` file.
105121

106122
On first start, if `GIT_REPO` is set and `/workspace` is empty, the entrypoint clones the repository. On subsequent restarts the existing clone is reused.
107123

108-
Without a deploy key, the service still works for general Claude Code usage git features are simply unavailable.
124+
Without a deploy key, the service still works for general Claude Code usage -- git features are simply unavailable.
109125

110126
### Optional Settings
111127

112128
| Variable | Default | Description |
113129
|----------|---------|-------------|
114130
| `ANTHROPIC_MODEL` | *(Claude default)* | Override the default model |
115131
| `CLAUDE_PERMISSION_MODE` | `acceptEdits` | Permission mode for `remote-control` (see below) |
116-
| `INIT_COMMAND` | *(empty)* | One-time setup command (runs once, persisted via stamp file) |
132+
| `INIT_COMMAND` | *(empty)* | One-time setup command (runs once on first launch, tracked via stamp file) |
117133
| `CLAUDE_EXTRA_ARGS` | *(empty)* | Extra flags for `claude remote-control` |
118134

119135
### Permission Modes
@@ -124,8 +140,8 @@ Controls what Claude Code can do without asking for confirmation:
124140
|------|----------|
125141
| `default` | Prompts for all file edits and commands |
126142
| `acceptEdits` | Auto-approves file edits, prompts for shell commands **(default)** |
127-
| `bypassPermissions` | Full autonomous / YOLO mode no prompts at all |
128-
| `plan` | Read-only planning mode no edits or commands |
143+
| `bypassPermissions` | Full autonomous / YOLO mode -- no prompts at all |
144+
| `plan` | Read-only planning mode -- no edits or commands |
129145

130146
To run fully autonomous:
131147
```bash
@@ -134,7 +150,7 @@ CLAUDE_PERMISSION_MODE=bypassPermissions
134150

135151
### Init Command
136152

137-
The `INIT_COMMAND` variable lets you install additional tools into the container on first boot. It runs once and is tracked via a stamp file in the Claude home volume, so it won't re-run on subsequent container restarts.
153+
The `INIT_COMMAND` variable lets you install additional tools into the container on first boot. It runs once and is tracked via a stamp file in the Claude config volume, so it won't re-run on subsequent container restarts.
138154

139155
```bash
140156
# Example: Install Python and build tools
@@ -145,7 +161,7 @@ INIT_COMMAND=apt-get update && apt-get install -y build-essential python3 python
145161

146162
| Volume | Container Path | Purpose |
147163
|--------|---------------|---------|
148-
| `claude_home` | `/opt/claude` | Claude config, credentials, history |
164+
| `claude_config` | `/home/node/.claude` | Claude credentials, config, and history (persists login across restarts) |
149165
| `claude_workspace` | `/workspace` | Project files (auto-cloned from `GIT_REPO`) |
150166

151167
## Connecting

services/claude-code/docker-compose.yml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,9 @@ services:
44
image: beevelop/claude:${CLAUDE_CODE_VERSION:-latest}
55
container_name: claude-code
66
volumes:
7-
- claude_home:/opt/claude
7+
- claude_config:/home/node/.claude
88
- claude_workspace:/workspace
99
environment:
10-
- ANTHROPIC_API_KEY=${ANTHROPIC_API_KEY}
11-
- CLAUDE_CODE_OAUTH_TOKEN=${CLAUDE_CODE_OAUTH_TOKEN:-}
1210
- ANTHROPIC_MODEL=${ANTHROPIC_MODEL:-}
1311
- CLAUDE_PERMISSION_MODE=${CLAUDE_PERMISSION_MODE:-acceptEdits}
1412
- DEPLOY_KEY_B64=${DEPLOY_KEY_B64:-}
@@ -34,8 +32,8 @@ services:
3432
stdin_open: true
3533

3634
volumes:
37-
claude_home:
38-
name: ${COMPOSE_PROJECT_NAME:-claude-code}_home
35+
claude_config:
36+
name: ${COMPOSE_PROJECT_NAME:-claude-code}_config
3937
claude_workspace:
4038
name: ${COMPOSE_PROJECT_NAME:-claude-code}_workspace
4139

0 commit comments

Comments
 (0)