Skip to content

Commit

Permalink
fixed docker-compose and prepopulation of mssql
Browse files Browse the repository at this point in the history
  • Loading branch information
lkurzyniec committed Jan 22, 2023
1 parent f6c49e0 commit 50fbe62
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 10 deletions.
11 changes: 6 additions & 5 deletions db/mssql/docker-db-init.sh
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions db/mssql/docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -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
5 changes: 3 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/HappyCode.NetCoreBoilerplate.Api/appsettings.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down

0 comments on commit 50fbe62

Please sign in to comment.