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:
commit
23524659e8
11
.env.example
Normal file
11
.env.example
Normal file
@ -0,0 +1,11 @@
|
||||
# ABOUTME: Environment variables for Claude Docker
|
||||
# ABOUTME: Copy this to ~/.claude-docker/.env and fill in your values
|
||||
|
||||
# Anthropic API key for Claude Code
|
||||
ANTHROPIC_API_KEY=your_anthropic_api_key_here
|
||||
|
||||
# Twilio credentials for SMS notifications
|
||||
TWILIO_ACCOUNT_SID=your_twilio_account_sid
|
||||
TWILIO_AUTH_TOKEN=your_twilio_auth_token
|
||||
TWILIO_PHONE_NUMBER=+1234567890 # Your Twilio phone number
|
||||
YOUR_PHONE_NUMBER=+1234567890 # Your personal phone to receive SMS
|
28
.gitignore
vendored
Normal file
28
.gitignore
vendored
Normal file
@ -0,0 +1,28 @@
|
||||
# Environment variables
|
||||
.env
|
||||
.env.local
|
||||
|
||||
# OS files
|
||||
.DS_Store
|
||||
Thumbs.db
|
||||
|
||||
# IDE files
|
||||
.idea/
|
||||
.vscode/
|
||||
*.swp
|
||||
*.swo
|
||||
|
||||
# Logs
|
||||
*.log
|
||||
logs/
|
||||
|
||||
# Node modules (if any local testing)
|
||||
node_modules/
|
||||
|
||||
# Docker volumes
|
||||
data/
|
||||
|
||||
# Temporary files
|
||||
*.tmp
|
||||
*.temp
|
||||
~*
|
40
Dockerfile
Normal file
40
Dockerfile
Normal file
@ -0,0 +1,40 @@
|
||||
# ABOUTME: Docker image for Claude Code with Twilio MCP server
|
||||
# ABOUTME: Provides autonomous Claude Code environment with SMS notifications
|
||||
|
||||
FROM node:20-slim
|
||||
|
||||
# Install required system dependencies
|
||||
RUN apt-get update && apt-get install -y \
|
||||
git \
|
||||
curl \
|
||||
python3 \
|
||||
build-essential \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Create app directory
|
||||
WORKDIR /app
|
||||
|
||||
# Install Claude Code globally
|
||||
RUN npm install -g @anthropic-ai/claude-code
|
||||
|
||||
# Install Twilio MCP server
|
||||
RUN npm install -g @twilioalpha/mcp-server-twilio
|
||||
|
||||
# Create directories for configuration
|
||||
RUN mkdir -p /app/config /app/.claude
|
||||
|
||||
# Copy MCP configuration
|
||||
COPY config/mcp-config.json /app/config/
|
||||
|
||||
# Copy startup script
|
||||
COPY scripts/startup.sh /app/
|
||||
RUN chmod +x /app/startup.sh
|
||||
|
||||
# Set working directory to mounted volume
|
||||
WORKDIR /workspace
|
||||
|
||||
# Environment variables will be passed from host
|
||||
ENV NODE_ENV=production
|
||||
|
||||
# Start both MCP server and Claude Code
|
||||
ENTRYPOINT ["/app/startup.sh"]
|
21
LICENSE
Normal file
21
LICENSE
Normal file
@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2025 Vishal Jain
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
14
config/mcp-config.json
Normal file
14
config/mcp-config.json
Normal file
@ -0,0 +1,14 @@
|
||||
{
|
||||
"mcpServers": {
|
||||
"twilio": {
|
||||
"command": "node",
|
||||
"args": ["/usr/lib/node_modules/@twilioalpha/mcp-server-twilio/build/index.js"],
|
||||
"env": {
|
||||
"TWILIO_ACCOUNT_SID": "${TWILIO_ACCOUNT_SID}",
|
||||
"TWILIO_AUTH_TOKEN": "${TWILIO_AUTH_TOKEN}",
|
||||
"TWILIO_PHONE_NUMBER": "${TWILIO_PHONE_NUMBER}",
|
||||
"YOUR_PHONE_NUMBER": "${YOUR_PHONE_NUMBER}"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
26
scratchpad.md
Normal file
26
scratchpad.md
Normal file
@ -0,0 +1,26 @@
|
||||
# Claude Docker Project Scratchpad
|
||||
|
||||
## Project Overview
|
||||
Building a Docker container that runs Claude Code with full autonomous permissions and Twilio SMS notifications upon task completion.
|
||||
|
||||
## Current Tasks
|
||||
- Setting up GitHub repository ✓
|
||||
- Creating project structure
|
||||
- Building Docker environment with Claude Code + Twilio MCP
|
||||
- Creating helper scripts for easy invocation
|
||||
|
||||
## Decisions Log
|
||||
- Using MCP (Model Context Protocol) for Twilio integration instead of direct API
|
||||
- Single container approach (no Docker Compose needed)
|
||||
- API keys via .env file
|
||||
- Context persistence via scratchpad.md files
|
||||
|
||||
## Notes & Context
|
||||
- Repository created at: https://github.com/VishalJ99/claude-docker
|
||||
- Using --dangerously-skip-permissions flag for full autonomy
|
||||
- Twilio MCP server will run alongside Claude Code in container
|
||||
|
||||
## Quick References
|
||||
- Claude Code docs: https://docs.anthropic.com/en/docs/claude-code
|
||||
- MCP docs: https://modelcontextprotocol.io/
|
||||
- Twilio MCP: https://twilioalpha.com/mcp
|
49
scripts/claude-docker.sh
Executable file
49
scripts/claude-docker.sh
Executable 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
40
scripts/install.sh
Executable 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
23
scripts/startup.sh
Executable 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 "$@"
|
28
templates/.claude/CLAUDE.md
Normal file
28
templates/.claude/CLAUDE.md
Normal file
@ -0,0 +1,28 @@
|
||||
# Claude Docker Project Context
|
||||
|
||||
This is a containerized Claude Code environment with full autonomous permissions.
|
||||
|
||||
## Important Instructions
|
||||
|
||||
1. **Context Persistence**: Always check for and use `scratchpad.md` in the project root:
|
||||
- Read it at the start of each session to understand project state
|
||||
- Update it throughout your work to track progress
|
||||
- Use it to maintain context between sessions
|
||||
|
||||
2. **Task Completion Notifications**: When you complete a major task:
|
||||
- Send an SMS notification using the Twilio MCP server
|
||||
- Format: "✅ Task complete | Task: [brief description] | Done: [what was accomplished]"
|
||||
- Keep it concise - just the essentials
|
||||
|
||||
3. **Working Environment**: You have full permissions to:
|
||||
- Execute any bash commands
|
||||
- Edit/create/delete any files
|
||||
- Access web resources
|
||||
- Manage the project autonomously
|
||||
|
||||
## MCP Server Available
|
||||
- Twilio MCP server is running and available for SMS notifications
|
||||
- Use natural language to send SMS messages
|
||||
- Example: "Send SMS to notify that the task is complete"
|
||||
|
||||
Remember: You're working in a safe containerized environment, so you can operate with full autonomy.
|
16
templates/scratchpad.md
Normal file
16
templates/scratchpad.md
Normal file
@ -0,0 +1,16 @@
|
||||
# Project Scratchpad
|
||||
|
||||
## Project Overview
|
||||
[Project description will be added here by Claude]
|
||||
|
||||
## Current Tasks
|
||||
[Active tasks being worked on]
|
||||
|
||||
## Decisions Log
|
||||
[Important decisions and their rationale]
|
||||
|
||||
## Notes & Context
|
||||
[Key insights, findings, and context]
|
||||
|
||||
## Quick References
|
||||
[Useful commands, paths, or references]
|
Loading…
Reference in New Issue
Block a user