-
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
·60 lines (52 loc) · 2.06 KB
/
Copy pathrun-dev-container.fish
File metadata and controls
executable file
·60 lines (52 loc) · 2.06 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
#!/usr/bin/env fish
# Helper script to run Claude Code development container
#
# Usage:
# ./run-dev-container.fish Run the devcontainer image
# ./run-dev-container.fish my-image:tag Run a custom container image
#
# The gcc/clang flavours this script used to accept are gone: they mapped to
# `make build-gcc` / `make build-clang`, which produced identical images
# because the SPACK_COMPILER build arg they passed was never declared by the
# Dockerfile. The dependency tree is built with GCC, fixed by the
# `packages: all: require:` line in .devcontainer/spack.yaml.
# Ensure we're in the project directory
cd (dirname (status --current-filename))
# Ensure ~/.claude-container exists
mkdir -p $HOME/.claude-container
# Default image (should match IMAGE_NAME in Makefile, tag built by `make build`)
set image_name shoccs-devcontainer
# Resolve the container image from the argument
set -q argv[1]; or set argv[1] $image_name:latest
set container $argv[1]
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"