-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathclaude-code-docker-run.ps1
More file actions
55 lines (45 loc) · 1.5 KB
/
claude-code-docker-run.ps1
File metadata and controls
55 lines (45 loc) · 1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
param (
[switch]$DebugMode,
[Parameter(ValueFromRemainingArguments=$true)]
[string[]]$remainingArgs
)
if ($DebugMode) {
$DebugPreference = 'Continue'
}
$ScriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
$DOCKER_IMG = "idachev/claude-code:latest"
if (-not $env:CLAUDE_CODE_HOME) {
$env:CLAUDE_CODE_HOME = $env:USERPROFILE
}
$ClaudeDir = Join-Path $env:CLAUDE_CODE_HOME ".claude"
if (-not (Test-Path $ClaudeDir)) {
New-Item -Path $ClaudeDir -ItemType Directory -Force | Out-Null
Write-Host "Created $ClaudeDir directory"
}
$ClaudeConfigFile = Join-Path $env:CLAUDE_CODE_HOME ".claude.json"
if (-not (Test-Path $ClaudeConfigFile)) {
"" | Out-File -FilePath $ClaudeConfigFile -Encoding utf8 -Force
Write-Host "Created $ClaudeConfigFile with empty JSON object"
}
$CURRENT_DIR = (Get-Location).Path
$CURRENT_DIR_BASENAME = Split-Path -Leaf $CURRENT_DIR
$DOCKER_NAME = "claude-code"
Write-Host "Pulling latest Docker image: $DOCKER_IMG"
& docker pull $DOCKER_IMG
if ($LASTEXITCODE -ne 0) {
Write-Error "Failed to pull Docker image"
exit 1
}
try {
& docker run -it --rm `
--name $DOCKER_NAME `
-v "${CURRENT_DIR}:/workspace/${CURRENT_DIR_BASENAME}" `
-v "${ClaudeDir}:/home/node/.claude" `
-v "${ClaudeConfigFile}:/home/node/.claude.json" `
--entrypoint /bin/zsh `
$DOCKER_IMG `
-c "cd /workspace/${CURRENT_DIR_BASENAME} && claude $remainingArgs && zsh"
} catch {
Write-Error "Error running Docker: $_"
exit 1
}