From 50fbe6253661c70c92cccbab1dc6b6a3b6aa05b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Kurzyniec?= Date: Sun, 22 Jan 2023 22:46:02 +0100 Subject: [PATCH] fixed docker-compose and prepopulation of mssql --- db/mssql/docker-db-init.sh | 11 ++++++----- db/mssql/docker-entrypoint.sh | 4 ++-- docker-compose.yml | 5 +++-- src/HappyCode.NetCoreBoilerplate.Api/appsettings.json | 2 +- 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/db/mssql/docker-db-init.sh b/db/mssql/docker-db-init.sh index 4dbb7575c..226f6f6f7 100644 --- a/db/mssql/docker-db-init.sh +++ b/db/mssql/docker-db-init.sh @@ -1,6 +1,7 @@ -#wait for the SQL Server to come up -sleep 30s +#!/bin/bash -echo "running set up script" -#run the setup script to create the DB and the schema in the DB -/opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P SomeStrongPwd123 -d master -i db-init.sql +echo "waiting 20s for the SQL Server to come up..." +sleep 20s + +echo "running set up script..." +/opt/mssql-tools/bin/sqlcmd -S "localhost" -U sa -P "${MSSQL_SA_PASSWORD}" -d master -i db-init.sql diff --git a/db/mssql/docker-entrypoint.sh b/db/mssql/docker-entrypoint.sh index b29f02a63..57fea6f7a 100644 --- a/db/mssql/docker-entrypoint.sh +++ b/db/mssql/docker-entrypoint.sh @@ -1,2 +1,2 @@ -#start SQL Server, start the script to create/setup the DB - /db-init.sh & /opt/mssql/bin/sqlservr +#!/bin/bash +/db-init.sh & /opt/mssql/bin/sqlservr diff --git a/docker-compose.yml b/docker-compose.yml index 3ca2d3f68..d6101f36e 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -22,14 +22,15 @@ services: mssql: image: mcr.microsoft.com/mssql/server:2019-latest + user: root container_name: mssql - command: /bin/bash ./entrypoint.sh + command: /bin/bash /entrypoint.sh ports: - 1433:1433 environment: - ACCEPT_EULA=Y - MSSQL_PID=Express - - SA_PASSWORD=SomeStrongPwd123 + - MSSQL_SA_PASSWORD=SomeStrongPwd123 volumes: - dbdata:/var/opt/mssql/data - ./db/mssql/docker-entrypoint.sh:/entrypoint.sh diff --git a/src/HappyCode.NetCoreBoilerplate.Api/appsettings.json b/src/HappyCode.NetCoreBoilerplate.Api/appsettings.json index 5ebe68975..f8173a272 100644 --- a/src/HappyCode.NetCoreBoilerplate.Api/appsettings.json +++ b/src/HappyCode.NetCoreBoilerplate.Api/appsettings.json @@ -1,7 +1,7 @@ { "ConnectionStrings": { "MySqlDb": "server=mysql;Database=employees;Uid=user;Pwd=simplepwd;", - "MsSqlDb": "Data Source=mssql;Initial Catalog=cars;User ID=user;Password=simplePWD123!" + "MsSqlDb": "Data Source=mssql;Initial Catalog=cars;User ID=user;Password=simplePWD123!;TrustServerCertificate=true;" }, "PingWebsite": {