# See change log for changes: https://www.texasstudentdatasystem.org/sites/texasstudentdatasystem.org/files/2023-2024-postaddendum-upgrade-change-log.pdf 
# TODO: need to update the changelog for 2025
# version: '3.9'
services:
  db:
    image: mcr.microsoft.com/mssql/server:2019-latest
    container_name: sqlServer-2025
    volumes:
      - data-volume:/var/opt/mssql
    environment:
      - SA_PASSWORD=${SA_PASSWORD}
      - ACCEPT_EULA=${ACCEPT_EULA}
      - MSSQL_PID=EXPRESS
    restart: on-failure
    ports:
      - '${SQL_SERVER_PORT}:1433'
    healthcheck:
      test: /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P "${SA_PASSWORD}" -Q "SELECT 1" -b -o /dev/null
      interval: 5s
      timeout: 5s
      retries: 5
      start_period: 10s
  db-tools:
    image: ghcr.io/teaivvdeploy/tsdsodssdk/dbtools:2025.1.0
    container_name: db-tools-2025
    volumes:
      - data-volume:/data
    environment:
      - SA_PASSWORD=${SA_PASSWORD}
    depends_on:
      - db
    stdin_open: true
    tty: true
    healthcheck:
      test: /opt/mssql-tools18/bin/sqlcmd -C -S db -U sa -P "${SA_PASSWORD}" -Q "SELECT db_id('TSDS_EdFi_Admin_2025')" -b -o /dev/null
      interval: 5s
      timeout: 5s
      retries: 5
      start_period: 10s  
  webapi:
    image: ghcr.io/teaivvdeploy/tsdsodssdk/webapi:2025.1.0
    environment:
      - SA_PASSWORD=${SA_PASSWORD}
      - TsdsEdFiApi_Password=${SA_PASSWORD}
      - ConnectionStrings:EdFi_Admin=Server=db;Database=TSDS_EdFi_Admin_2025;User ID=sa;Password=${SA_PASSWORD};Application Name=EdFi.Ods.WebApi;Integrated Security=false;TrustServerCertificate=True;
      - ConnectionStrings:EdFi_Master=Server=db;Database=master;User ID=sa;Password=${SA_PASSWORD};Application Name=EdFi.Ods.WebApi;Integrated Security=false;TrustServerCertificate=True;
      - ConnectionStrings:EdFi_Ods=Server=db;Database=TSDS_EdFi_Ods_701603_2025;User ID=sa;Password=${SA_PASSWORD};Application Name=EdFi.Ods.WebApi;Integrated Security=false;TrustServerCertificate=True;
      - ConnectionStrings:EdFi_Security=Server=db;Database=TSDS_EdFi_Security_2025;User ID=sa;Password=${SA_PASSWORD};persist security info=True;Application Name=EdFi.Ods.WebApi;Integrated Security=false;TrustServerCertificate=True;
    hostname: webapi2025
    container_name: webapi2025
    ports:
      - '${WEBAPI_PORT}:80'
    healthcheck:
      test: /opt/mssql-tools18/bin/sqlcmd -C -S db -U sa -P "${SA_PASSWORD}" -Q "SELECT db_id('TSDS_EdFi_Ods_701603_2025')" -b -o /dev/null
      interval: 5s
      timeout: 5s
      retries: 5
      start_period: 10s
    restart: always
    depends_on:
      - db	  
  swagger:
    image: ghcr.io/teaivvdeploy/tsdsodssdk/swagger:2025.1.0
    environment:
      # If launch swagger on the localhost with Windows or MacOS
      - WebApiVersionUrl=http://kubernetes.docker.internal:${WEBAPI_PORT}
      # If launch swagger on Linux or another host, then specify the host's IP
      # - WebApiVersionUrl=http://192.168.1.64:${WEBAPI_PORT}
      - POPULATED_SECRET=WvgLvbYdZ29OhUQZKdrA7ga1
      - POPULATED_KEY=Zzz13no8ZsiT
    hostname: swagger2025
    container_name: swagger2025
    ports:
      - '${SWAGGER_PORT}:80'
    healthcheck:
      test: /opt/mssql-tools18/bin/sqlcmd -C -S db -U sa -P "${SA_PASSWORD}" -Q "SELECT db_id('TSDS_EdFi_Admin_2025')" -b -o /dev/null
      interval: 5s
      timeout: 5s
      retries: 5
      start_period: 10s
    restart: always
    depends_on:
      - webapi	  
  adminapp:
    image: ghcr.io/teaivvdeploy/tsdsodssdk/adminapp:2025.1.0
    environment:
      # If launch adminapp on the localhost with Windows or MacOS
      - ProductionApiUrl=http://kubernetes.docker.internal:${WEBAPI_PORT}
      # If launch adminapp on Linux or another host, then specify the host's IP
      # - ProductionApiUrl=http://192.168.1.64:${WEBAPI_PORT}
      - ConnectionStrings:Admin=Server=db;Database=TSDS_EdFi_Admin_2025;User ID=sa;Password=${SA_PASSWORD};Application Name=EdFi.Ods.WebApi;Integrated Security=false;TrustServerCertificate=True;
      - ConnectionStrings:ProductionOds=Server=db;Database=TSDS_EdFi_{0}_2025;User ID=sa;Password=${SA_PASSWORD};Application Name=EdFi.Ods.WebApi;Integrated Security=false;TrustServerCertificate=True;
      - ConnectionStrings:Security=Server=db;Database=TSDS_EdFi_Security_2025;User ID=sa;Password=${SA_PASSWORD};persist security info=True;Application Name=EdFi.Ods.WebApi;Integrated Security=false;TrustServerCertificate=True;
      - SA_PASSWORD=${SA_PASSWORD}
    hostname: adminapp2025
    container_name: adminapp2025
    ports:
      - '${ADMINAPP_PORT}:80'
    healthcheck:
      test: /opt/mssql-tools18/bin/sqlcmd -C -S db -U sa -P "${SA_PASSWORD}" -Q "SELECT db_id('TSDS_EdFi_Admin_2025')" -b -o /dev/null
      interval: 5s
      timeout: 5s
      retries: 5
      start_period: 10s
    restart: always
    depends_on:
      - webapi	  
volumes:
  data-volume:
    driver: local
    name: sql-server-data-2025
