openclaw/docker-compose-full.yml
Claude Code e274d4d781 feat: add high availability and automation (v2.2)
This commit adds comprehensive high availability, disaster recovery,
and automation capabilities for enterprise-grade deployment.

High Availability Features:
- Keepalived integration for Virtual IP (38.14.254.100)
- Automatic failover monitoring and recovery
- PostgreSQL streaming replication support
- Health check scripts with auto-restart
- State change notifications

Disaster Recovery:
- Complete system backup script (database, configs, Docker volumes)
- Automated backup with retention policies
- Recovery manifest with step-by-step instructions
- Off-site backup support (S3, rsync ready)

Automation Tools:
- auto-deploy-server.sh - Deploy to remote server from local
- auto-deploy-server.bat - Windows version with WSL/Git Bash support
- deploy-oneclick.sh - One-click deployment on fresh server
- docker-compose-full.yml - Complete containerized stack

Container Orchestration:
- Full Docker Compose setup with all services
- Service dependencies and health checks
- Persistent volumes for data
- Network isolation with dedicated network
- Production-ready configuration

Deployment Automation:
- Automated dependency installation
- Database initialization with tables and indexes
- Monitoring stack auto-deployment
- Service auto-start via systemd
- Firewall auto-configuration
- Cron job automation

New Services:
- moltbot-failover.service - Auto-recovery monitor
- moltbot-metrics.service - Metrics exporter (9101)
- moltbot-log-analyzer.service - Log aggregation (9102)
- keepalived.service - VIP management

Documentation:
- HIGH-AVAILABILITY.md - Complete HA and automation guide

Architecture Improvements:
- Virtual IP for transparent failover
- Health-based service routing
- Automated disaster recovery backups
- Zero-touch server deployment
- Complete container orchestration support

Service Ports:
- Database API: 18800
- Metrics Exporter: 9101
- Log Analyzer: 9102
- Virtual IP: 38.14.254.100

🤖 Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>
2026-01-29 20:17:59 +08:00

192 lines
4.3 KiB
YAML

version: '3.8'
services:
# Moltbot Gateway
moltbot-gateway:
build:
context: .
dockerfile: Dockerfile.gateway
container_name: moltbot-gateway
ports:
- "18789:18789"
environment:
- NODE_ENV=production
- GATEWAY_MODE=hybrid
- GATEWAY_BIND=0.0.0.0
- GATEWAY_AUTH_TOKEN=moltbot-cluster-2024
volumes:
- moltbot-sessions:/root/.clawdbot/agents/main/sessions
- moltbot-config:/root/.clawdbot
depends_on:
- postgres
- redis
restart: unless-stopped
networks:
- moltbot-network
# Database API
moltbot-db-api:
build:
context: .
dockerfile: Dockerfile.db-api
container_name: moltbot-db-api
ports:
- "18800:18800"
environment:
- DB_HOST=postgres
- DB_PORT=5432
- DB_NAME=moltbot
- DB_USER=root
- DB_PASSWORD=
depends_on:
- postgres
restart: unless-stopped
networks:
- moltbot-network
# PostgreSQL Database
postgres:
image: postgres:14-alpine
container_name: moltbot-postgres
ports:
- "5432:5432"
environment:
- POSTGRES_DB=moltbot
- POSTGRES_USER=root
- POSTGRES_HOST_AUTH_METHOD=trust
volumes:
- postgres-data:/var/lib/postgresql/data
- ./init-db.sql:/docker-entrypoint-initdb.d/init-db.sql
restart: unless-stopped
networks:
- moltbot-network
# Redis (optional, for future use)
redis:
image: redis:7-alpine
container_name: moltbot-redis
ports:
- "6379:6379"
command: redis-server --appendonly yes
volumes:
- redis-data:/data
restart: unless-stopped
networks:
- moltbot-network
# Prometheus Metrics
prometheus:
image: prom/prometheus:latest
container_name: moltbot-prometheus
ports:
- "9090:9090"
volumes:
- ./prometheus/prometheus.yml:/etc/prometheus/prometheus.yml
- prometheus-data:/prometheus
command:
- '--config.file=/etc/prometheus/prometheus.yml'
- '--storage.tsdb.path=/prometheus'
restart: unless-stopped
networks:
- moltbot-network
# Grafana Visualization
grafana:
image: grafana/grafana:latest
container_name: moltbot-grafana
ports:
- "3000:3000"
environment:
- GF_SECURITY_ADMIN_USER=admin
- GF_SECURITY_ADMIN_PASSWORD=moltbot2024
- GF_USERS_ALLOW_SIGN_UP=false
- GF_INSTALL_PLUGINS=grafana-piechart-panel
volumes:
- grafana-data:/var/lib/grafana
- ./grafana/provisioning:/etc/grafana/provisioning
restart: unless-stopped
networks:
- moltbot-network
# Node Exporter (system metrics)
node-exporter:
image: prom/node-exporter:latest
container_name: moltbot-node-exporter
ports:
- "9100:9100"
command:
- '--path.procfs=/host/proc'
- '--path.sysfs=/host/sys'
- '--collector.filesystem.mount-points-exclude=^/(sys|proc|dev|host|etc)($$|/)'
volumes:
- /proc:/host/proc:ro
- /sys:/host/sys:ro
- /:/host:ro,rslave
restart: unless-stopped
networks:
- moltbot-network
# Moltbot Metrics Exporter
metrics-exporter:
build:
context: .
dockerfile: Dockerfile.metrics
container_name: moltbot-metrics-exporter
ports:
- "9101:9101"
environment:
- DB_HOST=postgres
- DB_PORT=5432
- DB_NAME=moltbot
- DB_USER=root
depends_on:
- postgres
restart: unless-stopped
networks:
- moltbot-network
# Log Analyzer
log-analyzer:
build:
context: .
dockerfile: Dockerfile.log-analyzer
container_name: moltbot-log-analyzer
ports:
- "9102:9102"
volumes:
- /var/log:/var/log/host:ro
- ./logs:/app/logs
restart: unless-stopped
networks:
- moltbot-network
# Nginx Reverse Proxy
nginx:
image: nginx:alpine
container_name: moltbot-nginx
ports:
- "80:80"
- "443:443"
volumes:
- ./nginx/nginx.conf:/etc/nginx/nginx.conf:ro
- ./nginx/ssl:/etc/nginx/ssl:ro
depends_on:
- moltbot-gateway
- grafana
- prometheus
restart: unless-stopped
networks:
- moltbot-network
volumes:
postgres-data:
redis-data:
prometheus-data:
grafana-data:
moltbot-sessions:
moltbot-config:
networks:
moltbot-network:
driver: bridge