# Local development database for the Balinyaar API.
#
# Brings up a throwaway SQL Server 2022 (Developer edition) on localhost:1433 so a developer with no
# access to any remote database can boot the API. On first run Program.cs applies all EF migrations and
# seeds roles + an admin user + a sandbox gateway against this empty instance.
#
# The SA password below is a well-known DEV-ONLY value: it is NOT a secret, is used only on localhost,
# and never reaches a deployed environment. Point the API at this instance via `dotnet user-secrets`
# (see dev/post-phase/refinement/RUNBOOK.md) — never by editing a committed appsettings*.json.
#
#   docker compose up -d
#   # then set ConnectionStrings:SqlServer via user-secrets (see the runbook), then `dotnet run`
#
# The API itself runs on the host via `dotnet run` (not in a container) for the local-dev loop — this
# compose file intentionally provisions only the database.

services:
  db:
    image: mcr.microsoft.com/mssql/server:2022-latest
    container_name: balinyaar-sqlserver
    environment:
      ACCEPT_EULA: "Y"
      MSSQL_PID: "Developer"
      MSSQL_SA_PASSWORD: "Balinyaar_Dev1433"
    ports:
      - "1433:1433"
    volumes:
      - balinyaar-mssql-data:/var/opt/mssql
    healthcheck:
      test: ["CMD-SHELL", "/opt/mssql-tools18/bin/sqlcmd -S localhost -U sa -P \"$${MSSQL_SA_PASSWORD}\" -C -Q 'SELECT 1' || exit 1"]
      interval: 10s
      timeout: 5s
      retries: 10
      start_period: 30s

volumes:
  balinyaar-mssql-data:
