# TSDS ODS3 SDK - version Rel_1.0.3.1
# TSDS ODS3 SDK - version Rel_1.0.1.2
# Fixed: ODS 3.X studentEducationOrganizationResponsibilityAssociations results in 403 when using a campus from different LEA
# TSDS ODS3 SDK - version Rel_1.0.1.1
# Change logs can be found here: https://www.texasstudentdatasystem.org/sites/texasstudentdatasystem.org/files/22_23_postaddendum4_ods_3.x_change_logs.pdf
# More info about data standards:  https://www.texasstudentdatasystem.org/tsds/teds/pilot-ods-3x-data-standards
# TSDS ODS3 SDK - version 0.1
# Basic functionalities: included TEA's extensions, descriptors, prepropulated learning district(701603) ODS database, a token to swagger and a test account for adminapi. 
version: '3.9'
services:
  db:
    image: mcr.microsoft.com/mssql/server:2019-latest
    container_name: sqlServer-2024
    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:2024.2.1.HF1
    container_name: db-tools-2024
    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')" -b -o /dev/null
      interval: 5s
      timeout: 5s
      retries: 5
      start_period: 10s  
  webapi:
    image: ghcr.io/teaivvdeploy/tsdsodssdk/webapi:2024.2.1.HF1
    environment:
      - ConnectionStrings:EdFi_Admin=Server=db;Database=TSDS_EdFi_Admin_2024;User ID=sa;Password=${SA_PASSWORD};Application Name=EdFi.Ods.WebApi;Integrated Security=false;
      - ConnectionStrings:EdFi_Master=Server=db;Database=master;User ID=sa;Password=${SA_PASSWORD};Application Name=EdFi.Ods.WebApi;Integrated Security=false;
      - ConnectionStrings:EdFi_Ods=Server=db;Database=TSDS_EdFi_{0}_2024;User ID=sa;Password=${SA_PASSWORD};Application Name=EdFi.Ods.WebApi;Integrated Security=false;
      - ConnectionStrings:EdFi_Security=Server=db;Database=TSDS_EdFi_Security_2024;User ID=sa;Password=${SA_PASSWORD};persist security info=True;Application Name=EdFi.Ods.WebApi;Integrated Security=false;
      - SA_PASSWORD=${SA_PASSWORD}
    hostname: webapi2024
    container_name: webapi2024
    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_2024')" -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:2024.2.1
    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: swagger2024
    container_name: swagger2024
    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_2024')" -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:2024.2.1.HF1
    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}
      - API_MODE=DistrictSpecific
      - ConnectionStrings:Admin=Server=db;Database=TSDS_EdFi_Admin_2024;User ID=sa;Password=${SA_PASSWORD};Application Name=EdFi.Ods.WebApi;Integrated Security=false;TrustServerCertificate=True;
      - ConnectionStrings:ProductionOds=Server=db;Database=TSDS_EdFi_{0}_2024;User ID=sa;Password=${SA_PASSWORD};Application Name=EdFi.Ods.WebApi;Integrated Security=false;TrustServerCertificate=True;
      - ConnectionStrings:Security=Server=db;Database=TSDS_EdFi_Security_2024;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: adminapp2024
    container_name: adminapp2024
    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_2024')" -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-2024
