services:
  mssql:
    image: mcr.microsoft.com/mssql/server:2022-latest
    container_name: mssql
    environment:
      - ACCEPT_EULA=Y
      - SA_PASSWORD=YourStrong@Password123
      - MSSQL_PID=Express
      - MSSQL_DATABASE=EpidemiologyDB
    ports:
      - "1433:1433"
    volumes:
      - mssql_data:/var/opt/mssql
      - mssql_data:/var/opt/mssql
      - ./init-scripts:/scripts
    healthcheck:
      test: /opt/mssql-tools18/bin/sqlcmd -S localhost -U sa -P "YourStrong@Password123" -C -Q "SELECT 1" || exit 1
      interval: 10s
      timeout: 3s
      retries: 10
      start_period: 30s
    restart: "no"

  # mssql-init:
  #   image: mcr.microsoft.com/mssql/server:2022-latest
  #   container_name: mssql-init
  #   depends_on:
  #     mssql:
  #       condition: service_healthy
  #   volumes:
  #     - ./init-scripts:/scripts
  #   command: >
  #     bash -c "
  #     echo 'SQL Server is ready, initializing database...'
  #     /opt/mssql-tools18/bin/sqlcmd -S mssql,1433 -U sa -P 'YourStrong@Password123' -C -i /scripts/init.sql
  #     echo 'Database initialization completed'
  #     "
  #   restart: "no"

volumes:
  mssql_data:
