-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathrun-dev-container.fish
More file actions
executable file
·61 lines (53 loc) · 1.91 KB
/
Copy pathrun-dev-container.fish
File metadata and controls
executable file
·61 lines (53 loc) · 1.91 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
56
57
58
59
60
61
#!/usr/bin/env fish
# Helper script to run Claude Code development container
#
# Usage:
# ./run-dev-container.fish Run the default (gcc) container
# ./run-dev-container.fish gcc Run the gcc container
# ./run-dev-container.fish clang Run the clang container
# ./run-dev-container.fish my-image:tag Run a custom container image
# Ensure we're in the project directory
cd (dirname (status --current-filename))
# Ensure ~/.claude-container exists
mkdir -p $HOME/.claude-container
# Default image name (should match IMAGE_NAME in Makefile)
set image_name shoccs-devcontainer
# Resolve the container image from the argument
set -q argv[1]; or set argv[1] gcc
switch $argv[1]
case gcc clang
set container $image_name:$argv[1]
case '*'
set container $argv[1]
end
set name (string split -r -m1 : $container)[1]
# Colors for output
set GREEN '\033[0;32m'
set BLUE '\033[0;34m'
set NC '\033[0m' # No Color
# Find a free host port (starting at 8000) to forward to container port 8000.
# Avoids "Bind for 0.0.0.0:8000 failed: port is already allocated" when another
# process/container already holds the port. No manual editing required.
set host_port 8000
while lsof -nP -iTCP:$host_port -sTCP:LISTEN >/dev/null 2>&1
set host_port (math $host_port + 1)
end
echo -e "$BLUE Starting $container ...$NC"
echo -e "$GREEN Forwarding host port $host_port -> container port 8000$NC"
echo ""
# Run container with all necessary configuration
docker run -it --rm \
--name $name \
--cap-add=NET_ADMIN \
--cap-add=NET_RAW \
-p $host_port:8000 \
-v (pwd):/workspace \
-v $HOME/.claude-container:/home/user/.claude \
-v $HOME/.gitconfig:/home/user/.gitconfig:ro \
-v $HOME/.ssh:/home/user/.ssh:ro \
-v claude-code-bashhistory:/commandhistory \
-e CLAUDE_CONFIG_DIR=/home/user/.claude \
-e POWERLEVEL9K_DISABLE_GITSTATUS=true \
--entrypoint /bin/bash \
$container \
-c "exec /bin/zsh"