diff --git a/docker-compose.yaml b/docker-compose.yaml index 74f1049..ae2489a 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -69,7 +69,8 @@ services: MSSQL_SA_PASSWORD: "4YiUmU2YJ8$6eqbSXF8765Ck3" MSSQL_PID: Developer healthcheck: - test: /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P "$${MSSQL_SA_PASSWORD}" -Q "SELECT 1" || exit 1 + test: ["CMD", "test", "-f", "/tmp/mssql.ready"] +# test: /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P "$${MSSQL_SA_PASSWORD}" -Q "SELECT 1" || exit 1 interval: 5s timeout: 5s retries: 5 diff --git a/local-env/mssql/initdb.sh b/local-env/mssql/initdb.sh index d84fdf7..ab713d8 100755 --- a/local-env/mssql/initdb.sh +++ b/local-env/mssql/initdb.sh @@ -13,13 +13,13 @@ echo "Waiting for SQL Server to start" while [[ $DBSTATUS -ne 0 ]] && [[ $i -lt $TRIES ]]; do i=$((i+1)) DBSTATUS=$(/opt/mssql-tools/bin/sqlcmd -h -1 -t 1 -U sa -P $MSSQL_SA_PASSWORD -Q "SET NOCOUNT ON; Select COALESCE(SUM(state), 0) from sys.databases") || DBSTATUS=1 - if [ $DBSTATUS -ne 0 ]; then + if [ $DBSTATUS -ne 0 ]; then sleep 1s fi done sleep 5s -if [ $DBSTATUS -ne 0 ]; then +if [ $DBSTATUS -ne 0 ]; then echo "SQL Server took more than $TRIES seconds to start up or one or more databases are not in an ONLINE state" exit 1 fi @@ -44,5 +44,6 @@ find /docker-entrypoint-initdb.d -mindepth 2 -type f | sort | while read f; do echo done +touch /tmp/mssql.ready echo "SQL Server is running" sleep infinity