version: '3.8'

# ===========================================
# AI App Builder - Local Development Services
# ===========================================
# Run: docker-compose up -d
# Stop: docker-compose down

services:
  # PostgreSQL Database (DISABLED - Using MongoDB Atlas)
  # postgres:
  #   image: postgres:16-alpine
  #   container_name: aab-postgres
  #   environment:
  #     POSTGRES_USER: postgres
  #     POSTGRES_PASSWORD: postgres
  #     POSTGRES_DB: ai_app_builder
  #   ports:
  #     - "5434:5432"
  #   volumes:
  #     - postgres_data:/var/lib/postgresql/data
  #   healthcheck:
  #     test: ["CMD-SHELL", "pg_isready -U postgres"]
  #     interval: 10s
  #     timeout: 5s
  #     retries: 5

  # Redis Cache
  redis:
    image: redis:7-alpine
    container_name: aab-redis
    ports:
      - "6379:6379"
    volumes:
      - redis_data:/data
    command: redis-server --appendonly yes
    healthcheck:
      test: ["CMD", "redis-cli", "ping"]
      interval: 10s
      timeout: 5s
      retries: 5

  # MinIO (S3-compatible storage for local dev)
  minio:
    image: minio/minio:latest
    container_name: aab-minio
    environment:
      MINIO_ROOT_USER: minioadmin
      MINIO_ROOT_PASSWORD: minioadmin
    ports:
      - "9000:9000"
      - "9001:9001"
    volumes:
      - minio_data:/data
    command: server /data --console-address ":9001"
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"]
      interval: 30s
      timeout: 20s
      retries: 3

  # Create MinIO buckets on startup
  minio-init:
    image: minio/mc:latest
    container_name: aab-minio-init
    depends_on:
      minio:
        condition: service_healthy
    entrypoint: >
      /bin/sh -c "
      mc alias set myminio http://minio:9000 minioadmin minioadmin;
      mc mb myminio/ai-app-builder-projects-dev --ignore-existing;
      mc mb myminio/ai-app-builder-artifacts-dev --ignore-existing;
      mc mb myminio/ai-app-builder-uploads-dev --ignore-existing;
      mc anonymous set public myminio/ai-app-builder-artifacts-dev;
      exit 0;
      "

  # pgAdmin (optional - database GUI) (DISABLED - Using MongoDB Atlas)
  # pgadmin:
  #   image: dpage/pgadmin4:latest
  #   container_name: aab-pgadmin
  #   environment:
  #     PGADMIN_DEFAULT_EMAIL: admin@admin.com
  #     PGADMIN_DEFAULT_PASSWORD: admin
  #   ports:
  #     - "5050:80"
  #   depends_on:
  #     postgres:
  #       condition: service_healthy
  #   profiles:
  #     - tools

  # Redis Commander (optional - Redis GUI)
  redis-commander:
    image: rediscommander/redis-commander:latest
    container_name: aab-redis-commander
    environment:
      REDIS_HOSTS: local:redis:6379
    ports:
      - "8081:8081"
    depends_on:
      redis:
        condition: service_healthy
    profiles:
      - tools

volumes:
  # postgres_data:  # Disabled - Using MongoDB Atlas
  redis_data:
  minio_data:

networks:
  default:
    name: ai-app-builder-network
