# HCFS Development Ecosystem
# Complete Docker Compose setup for HCFS-enabled agent development

version: '3.8'

services:
  # HCFS Core API Service
  hcfs-api:
    image: hcfs:latest
    container_name: hcfs-api
    ports:
      - "8000:8000"
    environment:
      - HCFS_DATABASE_URL=sqlite:///data/hcfs.db
      - HCFS_HOST=0.0.0.0
      - HCFS_PORT=8000
      - HCFS_LOG_LEVEL=info
    volumes:
      - hcfs-data:/data
      - hcfs-logs:/logs
    networks:
      - hcfs-network
    restart: unless-stopped
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:8000/health"]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 40s

  # HCFS RL Context Curator
  hcfs-rl-tuner:
    image: hcfs:latest
    container_name: hcfs-rl-tuner
    ports:
      - "8001:8001"
    environment:
      - HCFS_API_URL=http://hcfs-api:8000
      - RL_TUNER_HOST=0.0.0.0
      - RL_TUNER_PORT=8001
    volumes:
      - hcfs-rl-data:/data
    networks:
      - hcfs-network
    depends_on:
      - hcfs-api
    restart: unless-stopped
    command: ["python", "-m", "hcfs.rl_curator.rl_tuner_service"]

  # Python Development Agent
  agent-python:
    build:
      context: ./hcfs-python
      dockerfile: Dockerfile
    container_name: agent-python-dev
    ports:
      - "8888:8888"  # Jupyter
      - "8080:8080"  # Development server
    environment:
      - AGENT_ID=python-dev-agent
      - TASK_ID=development-task
      - HCFS_API_URL=http://hcfs-api:8000
      - HCFS_ENABLED=true
      - GIT_USER_NAME=HCFS Agent
      - GIT_USER_EMAIL=agent@hcfs.local
    volumes:
      - python-workspace:/home/agent/work
      - python-cache:/home/agent/.cache
    networks:
      - hcfs-network
    depends_on:
      - hcfs-api
    stdin_open: true
    tty: true
    restart: unless-stopped

  # Node.js Development Agent
  agent-nodejs:
    build:
      context: ./hcfs-nodejs
      dockerfile: Dockerfile
    container_name: agent-nodejs-dev
    ports:
      - "3000:3000"  # Node.js app
      - "9229:9229"  # Node.js debugger
    environment:
      - AGENT_ID=nodejs-dev-agent
      - TASK_ID=development-task
      - HCFS_API_URL=http://hcfs-api:8000
      - HCFS_ENABLED=true
      - NODE_ENV=development
    volumes:
      - nodejs-workspace:/home/agent/work
      - nodejs-cache:/home/agent/.npm
    networks:
      - hcfs-network
    depends_on:
      - hcfs-api
    stdin_open: true
    tty: true
    restart: unless-stopped

  # Go Development Agent
  agent-go:
    build:
      context: ./hcfs-go
      dockerfile: Dockerfile
    container_name: agent-go-dev
    ports:
      - "8090:8080"  # Go web server
      - "2345:2345"  # Delve debugger
    environment:
      - AGENT_ID=go-dev-agent
      - TASK_ID=development-task
      - HCFS_API_URL=http://hcfs-api:8000
      - HCFS_ENABLED=true
      - CGO_ENABLED=1
    volumes:
      - go-workspace:/home/agent/work
      - go-cache:/home/agent/.cache
    networks:
      - hcfs-network
    depends_on:
      - hcfs-api
    stdin_open: true
    tty: true
    restart: unless-stopped

  # Generic Development Agent (base image)
  agent-generic:
    build:
      context: ./hcfs-base
      dockerfile: Dockerfile
    container_name: agent-generic-dev
    ports:
      - "8050:8080"
    environment:
      - AGENT_ID=generic-dev-agent
      - TASK_ID=development-task
      - HCFS_API_URL=http://hcfs-api:8000
      - HCFS_ENABLED=true
    volumes:
      - generic-workspace:/home/agent/work
    networks:
      - hcfs-network
    depends_on:
      - hcfs-api
    stdin_open: true
    tty: true
    restart: unless-stopped

  # HCFS Management Dashboard (optional)
  hcfs-dashboard:
    image: nginx:alpine
    container_name: hcfs-dashboard
    ports:
      - "8080:80"
    volumes:
      - ./dashboard:/usr/share/nginx/html:ro
    networks:
      - hcfs-network
    depends_on:
      - hcfs-api
    restart: unless-stopped

  # Development Database (PostgreSQL for advanced features)
  postgres:
    image: postgres:15-alpine
    container_name: hcfs-postgres
    environment:
      - POSTGRES_DB=hcfs
      - POSTGRES_USER=hcfs
      - POSTGRES_PASSWORD=hcfs_password
    volumes:
      - postgres-data:/var/lib/postgresql/data
    networks:
      - hcfs-network
    restart: unless-stopped

  # Redis for caching and session management
  redis:
    image: redis:7-alpine
    container_name: hcfs-redis
    ports:
      - "6379:6379"
    volumes:
      - redis-data:/data
    networks:
      - hcfs-network
    restart: unless-stopped

  # MinIO for object storage (artifact storage)
  minio:
    image: minio/minio:latest
    container_name: hcfs-minio
    ports:
      - "9000:9000"
      - "9001:9001"
    environment:
      - MINIO_ROOT_USER=minioadmin
      - MINIO_ROOT_PASSWORD=minioadmin123
    volumes:
      - minio-data:/data
    networks:
      - hcfs-network
    command: server /data --console-address ":9001"
    restart: unless-stopped

networks:
  hcfs-network:
    driver: bridge
    ipam:
      config:
        - subnet: 172.20.0.0/16

volumes:
  # HCFS Core Data
  hcfs-data:
    driver: local
  hcfs-logs:
    driver: local
  hcfs-rl-data:
    driver: local

  # Agent Workspaces (persistent across container restarts)
  python-workspace:
    driver: local
  python-cache:
    driver: local
  nodejs-workspace:
    driver: local
  nodejs-cache:
    driver: local
  go-workspace:
    driver: local
  go-cache:
    driver: local
  generic-workspace:
    driver: local

  # Infrastructure Data
  postgres-data:
    driver: local
  redis-data:
    driver: local
  minio-data:
    driver: local