# 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 2026
# version: '3.9'
services:
  db:
    image: mcr.microsoft.com/mssql/server:2019-latest
    #Year Versioning: 2026.2.1
    container_name: sqlServer-2026

    #Year Versioning: 2025HotFix: 2025.2.2
    #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:
    #Year Versioning: 2026.2.1
    image: ghcr.io/teaivvdeploy/tsdsodssdk/dbtools:2026.2.1 #=> using Image from GitHub
    #image: dbtools:2026.2.1 #=> using Image from local Docker Desktop

    #Year Versioning: 2025HotFix: 2025.2.2
    #image: ghcr.io/teaivvdeploy/tsdsodssdk/dbtools:2025.2.2 #=> using Image from GitHub
    #image: dbtools:2025.2.2 #=> using Image from local Docker Desktop

    #Year Versioning: 2026.2.1
    container_name: db-tools-2026

    #Year Versioning: 2025HotFix: 2025.2.2
    #container_name: db-tools-2025
    volumes:
      - data-volume:/data
    environment:
      - SA_PASSWORD=${SA_PASSWORD}
    depends_on:
      - db
    stdin_open: true
    tty: true
    healthcheck:
      #Year Versioning: 2026.2.1
      test: /opt/mssql-tools18/bin/sqlcmd -C -S db -U sa -P "${SA_PASSWORD}" -Q "SELECT db_id('TSDS_EdFi_Admin_2026')" -b -o /dev/null

      #Year Versioning: 2025HotFix: 2025.2.2
      #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:
    #Year Versioning: 2026.2.1
    image: ghcr.io/teaivvdeploy/tsdsodssdk/webapi:2026.2.1 #=> using Image from GitHub
    #image: webapi:2026.2.1 #=> using Image from local Docker Desktop

    #Year Versioning: 2025HotFix: 2025.2.2
    #image: ghcr.io/teaivvdeploy/tsdsodssdk/webapi:2025.2.2 #=> using Image from GitHub
    #image: webapi:2025.2.2 #=> using Image from local Docker Desktop

    environment:
      #Year Versioning: 2026.2.1
      - SA_PASSWORD=${SA_PASSWORD}
      - TsdsEdFiApi_Password=${SA_PASSWORD}
      - ConnectionStrings:EdFi_Admin=Server=db;Database=TSDS_EdFi_Admin_2026;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_{0}_2026;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_2026;User ID=sa;Password=${SA_PASSWORD};persist security info=True;Application Name=EdFi.Ods.WebApi;Integrated Security=false;TrustServerCertificate=True;
    
      #Year Versioning: 2025HotFix: 2025.2.2
      #- 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_{0}_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;
    
    #Year Versioning: 2026.2.1
    hostname: webapi2026
    container_name: webapi2026

    #Year Versioning: 2025HotFix: 2025.2.2
    #hostname: webapi2025
    #container_name: webapi2025
    ports:
      - '${WEBAPI_PORT}:80'
    healthcheck:
      #Year Versioning: 2026.2.1
      test: /opt/mssql-tools18/bin/sqlcmd -C -S db -U sa -P "${SA_PASSWORD}" -Q "SELECT db_id('TSDS_EdFi_Ods_701603_2026')" -b -o /dev/null

      #Year Versioning: 2025HotFix: 2025.2.2
      #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:
    #Year Versioning: 2026.2.1
    image: ghcr.io/teaivvdeploy/tsdsodssdk/swagger:2026.2.1 #=> using Image from GitHub
    #image: swagger:2026.2.1 #=> using Image from local Docker Desktop

    #Year Versioning: 2025HotFix: 2025.2.2
    #image: ghcr.io/teaivvdeploy/tsdsodssdk/swagger:2025.2.2 #=> using Image from GitHub
    #image: swagger:2025.2.2 #=> using Image from local Docker Desktop

    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
    
    #Year Versioning: 2026.2.1
    hostname: swagger2026
    container_name: swagger2026

    #Year Versioning: 2025HotFix: 2025.2.2
    #hostname: swagger2025
    #container_name: swagger2025
    ports:
      - '${SWAGGER_PORT}:80'
    healthcheck:
      #Year Versioning: 2026.2.1
      test: /opt/mssql-tools18/bin/sqlcmd -C -S db -U sa -P "${SA_PASSWORD}" -Q "SELECT db_id('TSDS_EdFi_Admin_2026')" -b -o /dev/null

      #Year Versioning: 2025HotFix: 2025.2.2
      #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:
    #Year Versioning: 2026.2.1
    image: ghcr.io/teaivvdeploy/tsdsodssdk/adminapp:2026.2.1 #=> using Image from GitHub
    #image: adminapp:2026.2.1 #=> using Image from local Docker Desktop

    #Year Versioning: 2025HotFix: 2025.2.2
    #image: ghcr.io/teaivvdeploy/tsdsodssdk/adminapp:2025.2.2 #=> using Image from GitHub
    #image: adminapp:2025.2.2 #=> using Image from local Docker Desktop


    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}
      
      #Year Versioning: 2026.2.1
      - ConnectionStrings:Admin=Server=db;Database=TSDS_EdFi_Admin_2026;User ID=sa;Password=${SA_PASSWORD};Application Name=EdFi.Ods.WebApi;Integrated Security=false;TrustServerCertificate=True; 
      - ConnectionStrings:ProductionOds=Server=db;Database=TSDS_EdFi_{0}_2026;User ID=sa;Password=${SA_PASSWORD};Application Name=EdFi.Ods.WebApi;Integrated Security=false;TrustServerCertificate=True;
      - ConnectionStrings:Security=Server=db;Database=TSDS_EdFi_Security_2026;User ID=sa;Password=${SA_PASSWORD};persist security info=True;Application Name=EdFi.Ods.WebApi;Integrated Security=false;TrustServerCertificate=True;
      - SA_PASSWORD=${SA_PASSWORD}
 
    #Year Versioning: 2025HotFix: 2025.2.2
      #- 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}
    
    #Year Versioning: 2026.2.1
    hostname: adminapp2026
    container_name: adminapp2026

    #Year Versioning: 2025HotFix: 2025.2.2
    #hostname: adminapp2025
    #container_name: adminapp2025

    ports:
      - '${ADMINAPP_PORT}:80'
    healthcheck:
      #Year Versioning: 2026.2.1
      test: /opt/mssql-tools18/bin/sqlcmd -C -S db -U sa -P "${SA_PASSWORD}" -Q "SELECT db_id('TSDS_EdFi_Admin_2026')" -b -o /dev/null

      #Year Versioning: 2025HotFix: 2025.2.2
      #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
    #Year Versioning: 2026.2.1
    name: sql-server-data-2026

    #Year Versioning: 2025HotFix: 2025.2.2
    #name: sql-server-data-2025
