services:
 sqlserver:
    env_file: ".env.dev"
    image: mcr.microsoft.com/mssql/server:2022-latest
    platform: linux/amd64
    container_name: dev-env-sqlserver
    environment:
      ACCEPT_EULA: "Y"
      SA_PASSWORD: "${DB_PASSWORD}"
      MSSQL_PID: "Express"
    ports:
      - "1433:1433"
    volumes:
      - sqlserverdata-dev:/var/opt/mssql
    healthcheck:
      test: ["CMD-SHELL", "/opt/mssql-tools18/bin/sqlcmd -S localhost -U sa -P '${DB_PASSWORD}' -C -Q 'SELECT 1' || exit 1"]
      interval: 10s
      timeout: 5s
      retries: 12
      start_period: 30s
    networks:
      - devnet
 database.migrations:
    env_file: ".env.dev"
    image: database.migrations
    container_name: dev-env-database-migrations
    depends_on:
      sqlserver:
        condition: service_healthy
    build:
      context: ./src/Core/Database
      dockerfile: Database.Migrations/Dockerfile
      args:
        BUILD_CONFIGURATION: Release
        APP_UID: 1000
    environment:
      DOTNET_RUNNING_IN_CONTAINER: "true"
      DB_SERVER: "${DB_SERVER}"
      DB_NAME: "${DB_NAME}"
      DB_USER: "${DB_USER}"
      DB_PASSWORD: "${DB_PASSWORD}"
      CLEAR_DATABASE: "true"
    restart: "no"
    networks:
      - devnet

 database.seed:
    env_file: ".env.dev"
    image: database.seed
    container_name: dev-env-database-seed
    depends_on:
      database.migrations:
        condition: service_completed_successfully
    build:
      context: ./src/Core
      dockerfile: Database/Database.Seed/Dockerfile
      args:
        BUILD_CONFIGURATION: Release
        APP_UID: 1000
    environment:
      DOTNET_RUNNING_IN_CONTAINER: "true"
      DB_SERVER: "${DB_SERVER}"
      DB_NAME: "${DB_NAME}"
      DB_USER: "${DB_USER}"
      DB_PASSWORD: "${DB_PASSWORD}"
    restart: "no"
    networks:
      - devnet
volumes:
  sqlserverdata-dev:
    driver: local
  nuget-cache-dev:
    driver: local

networks:
  devnet:
    driver: bridge
