create-claude-docker 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,21 @@
1
+ {
2
+ "env": {
3
+ "ANTHROPIC_DEFAULT_HAIKU_MODEL": "glm-4.5-air",
4
+ "ANTHROPIC_DEFAULT_SONNET_MODEL": "glm-4.7",
5
+ "ANTHROPIC_DEFAULT_OPUS_MODEL": "glm-4.7",
6
+ "ANTHROPIC_AUTH_TOKEN": "${ANTHROPIC_API_KEY}",
7
+ "ANTHROPIC_BASE_URL": "https://api.z.ai/api/anthropic",
8
+ "API_TIMEOUT_MS": "3000000"
9
+ },
10
+ "permissions": {
11
+ "allow": [
12
+ "WebSearch",
13
+ "Bash(curl:*)",
14
+ "Bash(python3:*)",
15
+ "Bash(npm:*)",
16
+ "Bash(node:*)",
17
+ "Bash(mkdir:*)",
18
+ "Bash(git:*)"
19
+ ]
20
+ }
21
+ }
@@ -0,0 +1,47 @@
1
+ # Dockerfile for Claude Code development environment
2
+ # Runs as non-root user to support --dangerously-skip-permissions flag
3
+ # Supports both Anthropic Claude models and Z.AI GLM-4.7 models
4
+
5
+ FROM node:22-slim
6
+
7
+ # Install essential tools
8
+ RUN apt-get update && apt-get install -y \
9
+ git \
10
+ curl \
11
+ && rm -rf /var/lib/apt/lists/*
12
+
13
+ # Create non-root user for Claude Code (UID 2000 to avoid conflict with node user)
14
+ RUN useradd -m -s /bin/bash -u 2000 claude && \
15
+ mkdir -p /home/claude/.claude && \
16
+ chown -R claude:claude /home/claude
17
+
18
+ # Set working directory
19
+ WORKDIR /workspace
20
+
21
+ # Install Claude Code globally
22
+ RUN npm install -g @anthropic-ai/claude-code
23
+
24
+ # Copy default Claude Code configuration (settings + agents)
25
+ COPY --chown=claude:claude .claude /home/claude/.claude.defaults
26
+
27
+ # Switch to non-root user
28
+ USER claude
29
+
30
+ # Set up Claude Code config directory
31
+ ENV HOME=/home/claude
32
+ ENV CLAUDE_CONFIG_DIR=/home/claude/.claude
33
+
34
+ # Initialize default config on first run (if not already present)
35
+ RUN if [ ! -f /home/claude/.claude/settings.json ]; then \
36
+ cp -r /home/claude/.claude.defaults/* /home/claude/.claude/ 2>/dev/null || true; \
37
+ fi
38
+
39
+ # Copy entrypoint script
40
+ COPY --chown=claude:claude .docker/entrypoint.sh /home/claude/entrypoint.sh
41
+ RUN chmod +x /home/claude/entrypoint.sh
42
+
43
+ # Set entrypoint
44
+ ENTRYPOINT ["/home/claude/entrypoint.sh"]
45
+
46
+ # Default command
47
+ CMD ["tail", "-f", "/dev/null"]
@@ -0,0 +1,128 @@
1
+ #!/bin/bash
2
+ # Entrypoint script for Claude Code container
3
+ # Ensures Claude Code is properly configured with Z.AI API key
4
+
5
+ set -e
6
+
7
+ CLAUDE_DIR="/home/claude/.claude"
8
+ CLAUDE_DEFAULTS="/home/claude/.claude.defaults"
9
+ SETTINGS_FILE="$CLAUDE_DIR/settings.json"
10
+ CLAUDE_JSON_FILE="/home/claude/.claude.json"
11
+
12
+ echo "🚀 Starting Claude Code container..."
13
+
14
+ # Ensure .claude directory exists
15
+ mkdir -p "$CLAUDE_DIR"
16
+
17
+ # Copy defaults if they exist (agents, etc.)
18
+ if [ -d "$CLAUDE_DEFAULTS" ]; then
19
+ # Copy agents directory if not exists
20
+ if [ -d "$CLAUDE_DEFAULTS/agents" ] && [ ! -d "$CLAUDE_DIR/agents" ]; then
21
+ echo "📁 Copying default agents..."
22
+ cp -r "$CLAUDE_DEFAULTS/agents" "$CLAUDE_DIR/"
23
+ fi
24
+ fi
25
+
26
+ # CRITICAL: Create both ~/.claude.json AND ~/.claude/.claude.json with hasCompletedOnboarding flag
27
+ # Claude Code may check either location, so we set both
28
+ echo "🔧 Setting up onboarding bypass..."
29
+
30
+ # Update or create ~/.claude.json (HOME directory)
31
+ if [ -f "$CLAUDE_JSON_FILE" ]; then
32
+ node --eval '
33
+ const fs = require("fs");
34
+ const filePath = "'"$CLAUDE_JSON_FILE"'";
35
+ const content = JSON.parse(fs.readFileSync(filePath, "utf-8"));
36
+ content.hasCompletedOnboarding = true;
37
+ fs.writeFileSync(filePath, JSON.stringify(content, null, 2), "utf-8");
38
+ ' 2>/dev/null || echo '{"hasCompletedOnboarding": true}' > "$CLAUDE_JSON_FILE"
39
+ else
40
+ echo '{"hasCompletedOnboarding": true}' > "$CLAUDE_JSON_FILE"
41
+ fi
42
+
43
+ # Update or create ~/.claude/.claude.json (inside .claude directory)
44
+ CLAUDE_DIR_JSON="$CLAUDE_DIR/.claude.json"
45
+ if [ -f "$CLAUDE_DIR_JSON" ]; then
46
+ node --eval '
47
+ const fs = require("fs");
48
+ const filePath = "'"$CLAUDE_DIR_JSON"'";
49
+ const content = JSON.parse(fs.readFileSync(filePath, "utf-8"));
50
+ content.hasCompletedOnboarding = true;
51
+ fs.writeFileSync(filePath, JSON.stringify(content, null, 2), "utf-8");
52
+ ' 2>/dev/null || echo "Failed to update $CLAUDE_DIR_JSON"
53
+ else
54
+ echo '{"hasCompletedOnboarding": true}' > "$CLAUDE_DIR_JSON"
55
+ fi
56
+
57
+ echo "✅ Onboarding bypass configured (both locations)"
58
+
59
+ # ALWAYS regenerate settings.json with current environment variables
60
+ # This ensures the API key from .env is properly injected
61
+ echo "🔧 Configuring Claude Code settings..."
62
+
63
+ # Determine API key (ZAI_API_KEY takes precedence over ANTHROPIC_API_KEY)
64
+ API_KEY="${ZAI_API_KEY:-$ANTHROPIC_API_KEY}"
65
+
66
+ if [ -n "$API_KEY" ]; then
67
+ cat > "$SETTINGS_FILE" << EOF
68
+ {
69
+ "env": {
70
+ "ANTHROPIC_DEFAULT_HAIKU_MODEL": "glm-4.5-air",
71
+ "ANTHROPIC_DEFAULT_SONNET_MODEL": "glm-4.7",
72
+ "ANTHROPIC_DEFAULT_OPUS_MODEL": "glm-4.7",
73
+ "ANTHROPIC_AUTH_TOKEN": "$API_KEY",
74
+ "ANTHROPIC_BASE_URL": "https://api.z.ai/api/anthropic",
75
+ "API_TIMEOUT_MS": "3000000",
76
+ "CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": "1"
77
+ },
78
+ "permissions": {
79
+ "allow": [
80
+ "WebSearch",
81
+ "Bash(curl:*)",
82
+ "Bash(python3:*)",
83
+ "Bash(npm:*)",
84
+ "Bash(node:*)",
85
+ "Bash(mkdir:*)",
86
+ "Bash(git:*)"
87
+ ]
88
+ }
89
+ }
90
+ EOF
91
+ echo "✅ Claude Code configured with Z.AI API key"
92
+ else
93
+ echo "⚠️ WARNING: No API key found!"
94
+ echo " Please set ANTHROPIC_API_KEY or ZAI_API_KEY in your .env file"
95
+ # Create settings without API key (will fail authentication but shows config is working)
96
+ cat > "$SETTINGS_FILE" << EOF
97
+ {
98
+ "env": {
99
+ "ANTHROPIC_DEFAULT_HAIKU_MODEL": "glm-4.5-air",
100
+ "ANTHROPIC_DEFAULT_SONNET_MODEL": "glm-4.7",
101
+ "ANTHROPIC_DEFAULT_OPUS_MODEL": "glm-4.7",
102
+ "ANTHROPIC_BASE_URL": "https://api.z.ai/api/anthropic",
103
+ "API_TIMEOUT_MS": "3000000",
104
+ "CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": "1"
105
+ },
106
+ "permissions": {
107
+ "allow": [
108
+ "WebSearch",
109
+ "Bash(curl:*)",
110
+ "Bash(python3:*)",
111
+ "Bash(npm:*)",
112
+ "Bash(node:*)",
113
+ "Bash(mkdir:*)",
114
+ "Bash(git:*)"
115
+ ]
116
+ }
117
+ }
118
+ EOF
119
+ fi
120
+
121
+ echo "📋 Current settings.json:"
122
+ cat "$SETTINGS_FILE" | sed 's/"ANTHROPIC_AUTH_TOKEN": "[^"]*"/"ANTHROPIC_AUTH_TOKEN": "***HIDDEN***"/g'
123
+
124
+ echo "📋 Current ~/.claude.json:"
125
+ cat "$CLAUDE_JSON_FILE"
126
+
127
+ # Execute the main command
128
+ exec "$@"
@@ -0,0 +1,25 @@
1
+ # ============================================
2
+ # API KEY CONFIGURATION
3
+ # ============================================
4
+ # Choose ONE of the following options:
5
+
6
+ # ----------------------------------------
7
+ # OPTION 1: Z.AI GLM-4.7 (Recommended)
8
+ # ----------------------------------------
9
+ # Get your API key from: https://z.ai/manage-apikey/apikey-list
10
+ # or: https://open.bigmodel.cn/
11
+ #
12
+ # Use either ZAI_API_KEY (preferred):
13
+ ZAI_API_KEY=your-zai-api-key-here
14
+ #
15
+ # Or ANTHROPIC_API_KEY (both work):
16
+ # ANTHROPIC_API_KEY=your-zai-api-key-here
17
+
18
+ # ----------------------------------------
19
+ # OPTION 2: Anthropic Claude (Original)
20
+ # ----------------------------------------
21
+ # Get your API key from: https://console.anthropic.com/
22
+ # Note: If using Anthropic, you need to modify .claude/settings.json
23
+ # to remove Z.AI-specific settings (BASE_URL, model mappings)
24
+ #
25
+ # ANTHROPIC_API_KEY=sk-ant-xxxxx
@@ -0,0 +1,53 @@
1
+ # {{PROJECT_NAME}}
2
+
3
+ > {{PROJECT_DESCRIPTION}}
4
+
5
+ Docker-based Claude Code development environment with Z.AI GLM-4.7 support.
6
+
7
+ ## Quick Start
8
+
9
+ 1. **Configure API key:**
10
+ ```bash
11
+ # Edit .env and add your Z.AI API key
12
+ nano .env
13
+ ```
14
+
15
+ 2. **Build and start:**
16
+ ```bash
17
+ npm run docker:build
18
+ npm run docker:up
19
+ ```
20
+
21
+ 3. **Run Claude Code:**
22
+ ```bash
23
+ npm run claude:unsafe
24
+ ```
25
+
26
+ ## Commands
27
+
28
+ | Command | Description |
29
+ |---------|-------------|
30
+ | `npm run docker:build` | Build Docker image |
31
+ | `npm run docker:up` | Start container in background |
32
+ | `npm run docker:down` | Stop and remove container |
33
+ | `npm run docker:logs` | View container logs |
34
+ | `npm run docker:shell` | Open bash shell in container |
35
+ | `npm run claude` | Run Claude Code (normal mode) |
36
+ | `npm run claude:unsafe` | Run Claude Code with auto-approve |
37
+
38
+ ## Multi-line Prompts
39
+
40
+ | Method | How to use |
41
+ |--------|------------|
42
+ | **Ctrl+J** | Press `Ctrl+J` to insert a new line |
43
+ | **Backslash** | Type `\` before pressing Enter |
44
+
45
+ ## Configuration
46
+
47
+ - **API Key**: Set `ZAI_API_KEY` in `.env`
48
+ - **Settings**: Auto-generated on container start
49
+ - **Agents**: Add `.md` files to `.claude/agents/`
50
+
51
+ ---
52
+
53
+ Created with [create-claude-docker](https://github.com/fishinthenet/create-claude-docker)
@@ -0,0 +1,22 @@
1
+ services:
2
+ claude:
3
+ build:
4
+ context: .
5
+ dockerfile: .docker/Dockerfile
6
+ environment:
7
+ # API keys - ZAI_API_KEY takes precedence if both are set
8
+ - ANTHROPIC_API_KEY=${ANTHROPIC_API_KEY:-}
9
+ - ZAI_API_KEY=${ZAI_API_KEY:-}
10
+ # Terminal type for proper rendering
11
+ - TERM=xterm-256color
12
+ volumes:
13
+ # Mount project directory
14
+ - ./:/workspace
15
+ # Mount Claude Code config (isolated per project)
16
+ # Note: Default .claude config is copied during build, this volume allows overrides
17
+ - ./claude-data:/home/claude/.claude
18
+ # Optional: Mount git config from host (read-only)
19
+ - ${HOME}/.gitconfig:/home/claude/.gitconfig:ro
20
+ tty: true
21
+ stdin_open: true
22
+ command: tail -f /dev/null
@@ -0,0 +1,7 @@
1
+ # Environment variables
2
+ .env
3
+
4
+ # Claude Code local config (runtime overrides)
5
+ claude-data/
6
+
7
+ # Note: .claude/ directory is intentionally included as default configuration