Initial commit: Claude Docker setup

- Dockerfile with Claude Code and Twilio MCP integration
- Wrapper script for easy invocation from anywhere
- Auto-setup of .claude directory in projects
- SMS notifications via Twilio when tasks complete
- Installation script for zshrc alias
- Full autonomous permissions with --dangerously-skip-permissions
- Context persistence via scratchpad.md
This commit is contained in:
Vishal Jain
2025-06-11 10:29:15 +01:00
commit 23524659e8
12 changed files with 296 additions and 0 deletions

49
scripts/claude-docker.sh Executable file
View File

@@ -0,0 +1,49 @@
#!/bin/bash
# ABOUTME: Wrapper script to run Claude Code in Docker container
# ABOUTME: Handles project mounting, .claude setup, and environment variables
# Get the absolute path of the current directory
CURRENT_DIR=$(pwd)
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"
# Check if .claude directory exists in current project, create if not
if [ ! -d "$CURRENT_DIR/.claude" ]; then
echo "Creating .claude directory for this project..."
mkdir -p "$CURRENT_DIR/.claude"
# Copy template files
cp "$PROJECT_ROOT/templates/.claude/settings.local.json" "$CURRENT_DIR/.claude/"
cp "$PROJECT_ROOT/templates/.claude/CLAUDE.md" "$CURRENT_DIR/.claude/"
# Create scratchpad.md if it doesn't exist
if [ ! -f "$CURRENT_DIR/scratchpad.md" ]; then
cp "$PROJECT_ROOT/templates/scratchpad.md" "$CURRENT_DIR/"
fi
echo "✓ Claude configuration created"
fi
# Check if .env file exists in user's home claude-docker directory
ENV_FILE="$HOME/.claude-docker/.env"
if [ ! -f "$ENV_FILE" ]; then
echo "⚠️ No .env file found at $ENV_FILE"
echo "Please create it with your API keys. See .env.example for reference."
exit 1
fi
# Build the Docker image if it doesn't exist
if ! docker images | grep -q "claude-docker"; then
echo "Building Claude Docker image..."
docker build -t claude-docker:latest "$PROJECT_ROOT"
fi
# Run Claude Code in Docker
echo "Starting Claude Code in Docker..."
docker run -it --rm \
-v "$CURRENT_DIR:/workspace" \
-v "$ENV_FILE:/app/.env:ro" \
-v "$HOME/.claude-docker/config:/app/.claude:rw" \
--workdir /workspace \
--name claude-docker-session \
claude-docker:latest "$@"

40
scripts/install.sh Executable file
View File

@@ -0,0 +1,40 @@
#!/bin/bash
# ABOUTME: Installation script for claude-docker
# ABOUTME: Sets up alias and creates config directory
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"
# Create config directory
mkdir -p "$HOME/.claude-docker/config"
# Copy example env file if doesn't exist
if [ ! -f "$HOME/.claude-docker/.env" ]; then
cp "$PROJECT_ROOT/.env.example" "$HOME/.claude-docker/.env"
echo "⚠️ Created .env file at $HOME/.claude-docker/.env"
echo " Please edit it with your API keys!"
fi
# Add alias to .zshrc
ALIAS_LINE="alias claude='$PROJECT_ROOT/scripts/claude-docker.sh'"
if ! grep -q "alias claude=" "$HOME/.zshrc"; then
echo "" >> "$HOME/.zshrc"
echo "# Claude Docker alias" >> "$HOME/.zshrc"
echo "$ALIAS_LINE" >> "$HOME/.zshrc"
echo "✓ Added 'claude' alias to .zshrc"
else
echo "✓ Claude alias already exists in .zshrc"
fi
# Make scripts executable
chmod +x "$PROJECT_ROOT/scripts/claude-docker.sh"
chmod +x "$PROJECT_ROOT/scripts/startup.sh"
echo ""
echo "Installation complete! 🎉"
echo ""
echo "Next steps:"
echo "1. Edit $HOME/.claude-docker/.env with your API keys"
echo "2. Run 'source ~/.zshrc' or start a new terminal"
echo "3. Navigate to any project and run 'claude' to start"

23
scripts/startup.sh Executable file
View File

@@ -0,0 +1,23 @@
#!/bin/bash
# ABOUTME: Startup script for Claude Code container with MCP server
# ABOUTME: Launches Twilio MCP server then starts Claude Code with permissions bypass
# Load environment variables from .env if it exists
if [ -f /app/.env ]; then
export $(cat /app/.env | grep -v '^#' | xargs)
fi
# Start Twilio MCP server in the background
echo "Starting Twilio MCP server..."
npx @twilioalpha/mcp-server-twilio &
MCP_PID=$!
# Give MCP server time to start
sleep 2
# Configure Claude Code to use the MCP server
export CLAUDE_MCP_CONFIG=/app/config/mcp-config.json
# Start Claude Code with permissions bypass
echo "Starting Claude Code..."
exec claude-code --dangerously-skip-permissions "$@"