# Docker Compose for Local Development/Testing
# This allows you to test the microservices architecture locally
# Usage: docker-compose up -d

version: '3.8'

services:
  # Database
  mysql:
    image: mysql:8.0
    container_name: undateable-mysql
    environment:
      MYSQL_ROOT_PASSWORD: rootpassword
      MYSQL_DATABASE: undatable_me
      MYSQL_USER: undatable_user
      MYSQL_PASSWORD: undatable_pass
    ports:
      - "3306:3306"
    volumes:
      - mysql_data:/var/lib/mysql
      - ./database/schema.sql:/docker-entrypoint-initdb.d/schema.sql
    healthcheck:
      test: ["CMD", "mysqladmin", "ping", "-h", "localhost"]
      interval: 10s
      timeout: 5s
      retries: 5

  # Redis (optional - uncomment to enable)
  # redis:
  #   image: redis:7-alpine
  #   container_name: undateable-redis
  #   ports:
  #     - "6379:6379"
  #   command: redis-server --appendonly yes
  #   volumes:
  #     - redis_data:/data

  # Auth Service
  auth-service:
    build:
      context: .
      dockerfile: docker/Dockerfile.auth
    container_name: undateable-auth
    ports:
      - "8001:8001"
    environment:
      - DB_HOST=mysql
      - DB_NAME=undatable_me
      - DB_USER=undatable_user
      - DB_PASS=undatable_pass
      - AWS_REGION=us-east-1
      - REDIS_ENABLED=false
      # - REDIS_HOST=redis
      - JWT_SECRET=local-development-secret-change-in-production
    depends_on:
      mysql:
        condition: service_healthy
    networks:
      - undateable-network

  # Profiles Service
  profiles-service:
    build:
      context: .
      dockerfile: docker/Dockerfile.profiles
    container_name: undateable-profiles
    ports:
      - "8002:8002"
    environment:
      - DB_HOST=mysql
      - DB_NAME=undatable_me
      - DB_USER=undatable_user
      - DB_PASS=undatable_pass
      - AWS_REGION=us-east-1
      - REDIS_ENABLED=false
      - S3_BUCKET=local-development-bucket
      - JWT_SECRET=local-development-secret-change-in-production
    depends_on:
      mysql:
        condition: service_healthy
    networks:
      - undateable-network

  # Messaging Service
  messaging-service:
    build:
      context: .
      dockerfile: docker/Dockerfile.messaging
    container_name: undateable-messaging
    ports:
      - "8003:8003"
    environment:
      - DB_HOST=mysql
      - DB_NAME=undatable_me
      - DB_USER=undatable_user
      - DB_PASS=undatable_pass
      - AWS_REGION=us-east-1
      - REDIS_ENABLED=false
      - S3_BUCKET=local-development-bucket
      - JWT_SECRET=local-development-secret-change-in-production
    depends_on:
      mysql:
        condition: service_healthy
    networks:
      - undateable-network

  # Burn Service
  burn-service:
    build:
      context: .
      dockerfile: docker/Dockerfile.burn
    container_name: undateable-burn
    ports:
      - "8004:8004"
    environment:
      - DB_HOST=mysql
      - DB_NAME=undatable_me
      - DB_USER=undatable_user
      - DB_PASS=undatable_pass
      - AWS_REGION=us-east-1
      - REDIS_ENABLED=false
      - JWT_SECRET=local-development-secret-change-in-production
    depends_on:
      mysql:
        condition: service_healthy
    networks:
      - undateable-network

  # WebSocket Service
  websocket-service:
    build:
      context: ./websocket-service
      dockerfile: Dockerfile
    container_name: undateable-websocket
    ports:
      - "8005:8005"
    environment:
      - DB_HOST=mysql
      - DB_NAME=undatable_me
      - DB_USER=undatable_user
      - DB_PASS=undatable_pass
      - WS_PORT=8005
      - NODE_ENV=development
      - REDIS_ENABLED=false
      # - REDIS_HOST=redis
      - JWT_SECRET=local-development-secret-change-in-production
      - CORS_ORIGINS=http://localhost:3000,http://localhost:80
    depends_on:
      mysql:
        condition: service_healthy
    networks:
      - undateable-network

  # Frontend Service (undateable.me)
  frontend-service:
    build:
      context: .
      dockerfile: docker/Dockerfile.frontend
    container_name: undateable-frontend
    ports:
      - "80:80"
    environment:
      - DB_HOST=mysql
      - DB_NAME=undatable_me
      - DB_USER=undatable_user
      - DB_PASS=undatable_pass
      - AWS_REGION=us-east-1
      - REDIS_ENABLED=false
      - S3_BUCKET=local-development-bucket
      - JWT_SECRET=local-development-secret-change-in-production
    depends_on:
      mysql:
        condition: service_healthy
    networks:
      - undateable-network

  # BurnYourEx Frontend
  burnyourex-frontend:
    build:
      context: /Users/ryan/development/burnyourex.games
      dockerfile: Dockerfile
    container_name: burnyourex-frontend
    ports:
      - "3000:80"
    networks:
      - undateable-network

networks:
  undateable-network:
    driver: bridge

volumes:
  mysql_data:
  # redis_data:  # Uncomment if using Redis
