services:
  web:
    image: lovasoa/sqlpage:main
    ports:
      - "8080:8080"
    volumes:
      - .:/var/www
      - ./sqlpage:/etc/sqlpage
    depends_on:
      - db
    environment:
      RUST_LOG: sqlpage=debug
      DATABASE_URL: mssql://sa:YourStrong!Passw0rd@db:1433/
  db:
    image: mcr.microsoft.com/mssql/server:2022-latest
    volumes:
      - ./sqlpage/mssql-migrations:/migrations
    environment:
      ACCEPT_EULA: Y
      MSSQL_SA_PASSWORD: YourStrong!Passw0rd
      MSSQL_PID: Express
    command: >
      bash -c "
        /opt/mssql/bin/sqlservr &
        until /opt/mssql-tools18/bin/sqlcmd -S localhost -U sa -P YourStrong!Passw0rd -C -Q 'SELECT 1;'; do
          echo 'Waiting for database...'
          sleep 1
        done
        /opt/mssql-tools18/bin/sqlcmd -S localhost -U sa -P YourStrong!Passw0rd -C -i /migrations/0001_db_init.sql
        tail -f /dev/null"
