claude-code-proxy/docker-entrypoint.sh
Arseniy Ivanov cb36631b7a Fix Docker implementation with working SQLite and healthcheck
- Enable CGO in Go build stage for SQLite support (add gcc, musl-dev, sqlite-dev)
- Replace PM2 with direct process management for simpler container operation
- Fix network binding to 0.0.0.0 for external access from host
- Simplify healthcheck command to avoid spider mode issues
- Remove PM2 dependency and use background processes with proper signal handling
- Both proxy (3001) and web (5173) services now start and respond correctly

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-03 19:30:32 -04:00

63 lines
No EOL
1.7 KiB
Bash

#!/bin/sh
# Docker entrypoint script for Claude Code Proxy
# Starts both the Go proxy server and Remix frontend
set -e
echo "🚀 Starting Claude Code Proxy services..."
echo "========================================="
# Function to handle graceful shutdown
cleanup() {
echo ""
echo "🛑 Shutting down services..."
kill $PROXY_PID $WEB_PID 2>/dev/null || true
exit 0
}
# Trap signals for graceful shutdown
trap cleanup SIGTERM SIGINT
echo "📊 Configuration:"
echo " - Proxy Server: http://0.0.0.0:${PORT}"
echo " - Web Dashboard: http://0.0.0.0:${WEB_PORT}"
echo " - Database: ${DB_PATH}"
echo " - Anthropic API: ${ANTHROPIC_FORWARD_URL}"
echo "========================================="
# Start proxy server
echo "🔄 Starting proxy server..."
PORT=${PORT} \
READ_TIMEOUT=${READ_TIMEOUT}s \
WRITE_TIMEOUT=${WRITE_TIMEOUT}s \
IDLE_TIMEOUT=${IDLE_TIMEOUT}s \
ANTHROPIC_FORWARD_URL=${ANTHROPIC_FORWARD_URL} \
ANTHROPIC_VERSION=${ANTHROPIC_VERSION} \
ANTHROPIC_MAX_RETRIES=${ANTHROPIC_MAX_RETRIES} \
DB_PATH=${DB_PATH} \
./bin/proxy &
PROXY_PID=$!
# Wait for proxy to start
sleep 3
# Start web server
echo "🔄 Starting web server..."
cd web
PORT=${WEB_PORT} HOST=0.0.0.0 NODE_ENV=production npx remix-serve build/server/index.js &
WEB_PID=$!
cd ..
echo ""
echo "✨ All services started successfully!"
echo "========================================="
echo "📊 Web Dashboard: http://localhost:${WEB_PORT}"
echo "🔌 API Proxy: http://localhost:${PORT}"
echo "💚 Health Check: http://localhost:${PORT}/health"
echo "========================================="
echo "💡 To use with Claude Code, set: ANTHROPIC_BASE_URL=http://localhost:${PORT}"
echo ""
# Wait for processes to finish
wait