claude-code-stack/claude-code-stack-docker-compose.yml
Zac Gaetano f46a4749cf Implement claude auth login + repo cleanup
- Dockerfile: entrypoint bootstraps ~/.claude/.credentials.json from ANTHROPIC_API_KEY (non-interactive auth, no manual claude auth login needed); fix build stage; add jq
- docker-compose.yml: fix build context; update model to claude-sonnet-4-6; pass ANTHROPIC_MODEL env; fix backend healthcheck
- claude-code-stack.env: update models to claude-sonnet-4-6; add CLAUDE_CONFIG_DIR; document auth strategy
- deploy-ssh.sh: add verify_auth step; fix file aliasing on remote; auto-generate secrets; better output
- README.md: document full auth flow end-to-end; add useful commands table
2026-04-04 15:09:26 -04:00

170 lines
5.5 KiB
YAML

version: '3.8'
# ============================================================================
# Claude Code Stack - Docker Compose
# Services: Claude Agents UI + Claude Code Runtime + PostgreSQL + Redis + Nginx
# ============================================================================
services:
# --------------------------------------------------------------------------
# Claude Code Agents UI
# Nuxt 3 frontend for managing agents, commands, skills, and workflows.
# Reads/writes ~/.claude directory for all configuration storage.
# --------------------------------------------------------------------------
agents-ui:
build:
context: .
dockerfile: claude-agents-ui-Dockerfile
image: claude-agents-ui:latest
container_name: claude-agents-ui
restart: unless-stopped
ports:
- "3000:3000"
environment:
# Required: Anthropic API key - used by the entrypoint for `claude auth`
ANTHROPIC_API_KEY: ${ANTHROPIC_API_KEY}
# Claude config directory inside the container
CLAUDE_CONFIG_DIR: /root/.claude
CLAUDE_DIR: /root/.claude
# Model selection (passed through to the UI / Claude Code runtime)
ANTHROPIC_MODEL: ${CLAUDE_MODEL:-claude-sonnet-4-6}
NODE_ENV: ${NODE_ENV:-production}
volumes:
# Persist Claude credentials and config across restarts
- claude-config:/root/.claude
# Shared workspace for agent projects
- workspace:/workspace
networks:
- claude-stack
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:3000"]
interval: 30s
timeout: 10s
retries: 3
start_period: 60s
# --------------------------------------------------------------------------
# Claude Code Runtime (Backend)
# Provides the Claude Code CLI execution environment.
# Uses ANTHROPIC_API_KEY directly - no interactive auth needed.
# --------------------------------------------------------------------------
claude-code-backend:
image: ghcr.io/anthropics/claude-code:latest
container_name: claude-code-runtime
restart: unless-stopped
environment:
# Required: API key for non-interactive claude execution
ANTHROPIC_API_KEY: ${ANTHROPIC_API_KEY}
# Model selection
ANTHROPIC_MODEL: ${CLAUDE_MODEL:-claude-sonnet-4-6}
# Optional: custom API endpoint
# ANTHROPIC_BASE_URL: https://api.anthropic.com
WORKSPACE_DIR: /workspace
# Run claude in non-interactive mode by default
CLAUDE_CODE_DISABLE_NONINTERACTIVE_PROMPT: "false"
volumes:
# Share Claude config with agents-ui (credentials, agents, settings)
- claude-config:/root/.claude
# Shared workspace
- workspace:/workspace
# Optional: SSH keys for git operations (read-only)
# - ${HOME}/.ssh:/root/.ssh:ro
networks:
- claude-stack
healthcheck:
test: ["CMD", "sh", "-c", "test -d /workspace && echo ok"]
interval: 30s
timeout: 10s
retries: 3
# --------------------------------------------------------------------------
# PostgreSQL - Agent data persistence
# --------------------------------------------------------------------------
postgres:
image: postgres:16-alpine
container_name: claude-postgres
restart: unless-stopped
ports:
- "5432:5432"
environment:
POSTGRES_USER: ${POSTGRES_USER:-claude}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-changeMe123!}
POSTGRES_DB: ${POSTGRES_DB:-claude_agents}
volumes:
- postgres-data:/var/lib/postgresql/data
networks:
- claude-stack
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-claude}"]
interval: 10s
timeout: 5s
retries: 5
# --------------------------------------------------------------------------
# Redis - Caching and session management
# --------------------------------------------------------------------------
redis:
image: redis:7-alpine
container_name: claude-redis
restart: unless-stopped
ports:
- "6379:6379"
volumes:
- redis-data:/data
networks:
- claude-stack
command: redis-server --appendonly yes
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 10s
timeout: 5s
retries: 5
# --------------------------------------------------------------------------
# Nginx - Reverse proxy for production
# --------------------------------------------------------------------------
nginx:
image: nginx:alpine
container_name: claude-nginx
restart: unless-stopped
ports:
- "80:80"
- "443:443"
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf:ro
# Uncomment to enable SSL:
# - ./certs:/etc/nginx/certs:ro
depends_on:
- agents-ui
networks:
- claude-stack
healthcheck:
test: ["CMD", "wget", "--quiet", "--tries=1", "--spider", "http://localhost"]
interval: 30s
timeout: 10s
retries: 3
# ============================================================================
# Volumes
# ============================================================================
volumes:
# Claude config/credentials - persists auth state across restarts
claude-config:
driver: local
# Shared workspace for agent projects
workspace:
driver: local
# PostgreSQL data
postgres-data:
driver: local
# Redis AOF data
redis-data:
driver: local
# ============================================================================
# Networks
# ============================================================================
networks:
claude-stack:
driver: bridge