services:
  mongodb-wms:
    image: mongo:latest
    container_name: mongodb_wms
    ports:
      - "27017:27017"
    volumes:
      - mongodb_data:/data/db # Persist MongoDB data
    networks:
      - wms-network

  # Customer Service
  customer-service: # Docker Compose service name (lowercase)
    build:
      context: ./Customer-Services # <--- Exact folder name with capitalization
      dockerfile: Dockerfile
    container_name: wms_customer_service
    ports:
      - "8087:8087"
    depends_on:
      - mongodb-wms
    networks:
      - wms-network
    environment:
      # MongoDB URI uses the Docker Compose service name for MongoDB
      MONGODB_URI: mongodb://mongodb-wms:27017
      DATABASE_NAME: wms_customer_db
      PORT: 8087

  # Warehouse Service
  warehouse-service: # Docker Compose service name (lowercase)
    build:
      context: ./Warehouse-Services # <--- Exact folder name with capitalization
      dockerfile: Dockerfile
    container_name: wms_warehouse_service
    ports:
      - "8085:8085"
    depends_on:
      - mongodb-wms
    networks:
      - wms-network
    environment:
      MONGODB_URI: mongodb://mongodb-wms:27017
      DATABASE_NAME: wms_warehouse_db
      PORT: 8085

  # Commodity Service
  commodity-service: # Docker Compose service name (lowercase)
    build:
      context: ./commodity-service # <--- Exact folder name with capitalization
      dockerfile: Dockerfile
    container_name: wms_commodity_service
    ports:
      - "8086:8086"
    depends_on:
      - mongodb-wms
    networks:
      - wms-network
    environment:
      MONGODB_URI: mongodb://mongodb-wms:27017
      DATABASE_NAME: wms_commodities_db
      PORT: 8086

  # Inventory Service
  inventory-service: # Docker Compose service name (lowercase)
    build:
      context: ./Inventory-Services # <--- Exact folder name with capitalization
      dockerfile: Dockerfile
    container_name: wms_inventory_service
    ports:
      - "8088:8088"
    depends_on:
      - mongodb-wms
    networks:
      - wms-network
    environment:
      MONGODB_URI: mongodb://mongodb-wms:27017
      DATABASE_NAME: wms_inventory_db
      PORT: 8088

  # API Gateway
  api-gateway: # Docker Compose service name (lowercase)
    build:
      context: ./api-gateway # <--- Exact folder name with capitalization
      dockerfile: Dockerfile
    container_name: wms_api_gateway
    ports:
      - "8080:8080"
    depends_on:
      - mongodb-wms
      - customer-service # Dependency using Docker Compose service name
      - warehouse-service
      - commodity-service
      - inventory-service
    networks:
      - wms-network
    environment:
      # URLs for other services (use their Docker Compose service names)
      CUSTOMER_SERVICE_URL: http://customer-service:8087
      WAREHOUSE_SERVICE_URL: http://warehouse-service:8085
      COMMODITIES_SERVICE_URL: http://commodity-service:8086
      INVENTORY_SERVICE_URL: http://inventory-service:8088
      PORT: 8080

volumes:
  mongodb_data:

networks:
  wms-network:
    driver: bridge
