services:
  mssql:
    image: mcr.microsoft.com/mssql/server:2022-latest
    container_name: bimai-mssql
    hostname: bimai-mssql
    environment:
      - ACCEPT_EULA=Y
      - SA_PASSWORD=BimAI_Dev_Pass_2024!
      - MSSQL_PID=Developer
    ports:
      - "1433:1433"
    volumes:
      - mssql-data:/var/opt/mssql
      - ./docker/mssql/init:/docker-entrypoint-initdb.d
    networks:
      - bimai-network
    healthcheck:
      test: /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P "BimAI_Dev_Pass_2024!" -Q "SELECT 1" || exit 1
      interval: 10s
      timeout: 3s
      retries: 10
      start_period: 10s

  mongodb:
    image: mongo:7.0
    container_name: bimai-mongodb
    hostname: bimai-mongodb
    environment:
      - MONGO_INITDB_ROOT_USERNAME=admin
      - MONGO_INITDB_ROOT_PASSWORD=BimAI_Mongo_2024!
      - MONGO_INITDB_DATABASE=bimai
    ports:
      - "27017:27017"
    volumes:
      - mongodb-data:/data/db
      - mongodb-config:/data/configdb
      - ./docker/mongodb/init:/docker-entrypoint-initdb.d
    networks:
      - bimai-network
    healthcheck:
      test: echo 'db.runCommand("ping").ok' | mongosh localhost:27017/test --quiet
      interval: 10s
      timeout: 5s
      retries: 5
      start_period: 10s

networks:
  bimai-network:
    driver: bridge

volumes:
  mssql-data:
    name: bimai-mssql-data
  mongodb-data:
    name: bimai-mongodb-data
  mongodb-config:
    name: bimai-mongodb-config