add mssql

This commit is contained in:
2021-08-18 01:46:32 -05:00
parent 372c1ad35d
commit 1d808a59b2
5 changed files with 58 additions and 0 deletions

3
db/mssql/Dockerfile Normal file
View File

@@ -0,0 +1,3 @@
FROM mcr.microsoft.com/mssql/server:2017-latest
CMD /bin/bash /docker-entrypoint-initdb.d/entrypoint.sh

3
db/mssql/entrypoint.sh Executable file
View File

@@ -0,0 +1,3 @@
#!/bin/bash
/docker-entrypoint-initdb.d/run-initialization.sh & /opt/mssql/bin/sqlservr

27
db/mssql/init.sql Normal file
View File

@@ -0,0 +1,27 @@
EXEC sp_configure 'CONTAINED DATABASE AUTHENTICATION', 1
GO
RECONFIGURE
GO
USE [master]
GO
CREATE DATABASE demo;
GO
ALTER DATABASE [demo] SET CONTAINMENT = PARTIAL
GO
USE [demo];
GO
CREATE USER demo_user WITH PASSWORD = 'pas$w0rd';
GO
CREATE TABLE Products (ID int, ProductName nvarchar(max));
GO
GRANT SELECT ON OBJECT::dbo.Products TO demo_user;
GRANT INSERT ON OBJECT::dbo.Products TO demo_user;
GRANT UPDATE ON OBJECT::dbo.Products TO demo_user;
GRANT DELETE ON OBJECT::dbo.Products TO demo_user;

7
db/mssql/run-initialization.sh Executable file
View File

@@ -0,0 +1,7 @@
#!/bin/bash
# Wait to be sure that SQL Server came up
sleep 20s
# Run the setup script to create the DB and the schema in the DB
# Note: make sure that your password matches what is in the Dockerfile
/opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P ${SA_PASSWORD} -d master -i /docker-entrypoint-initdb.d/init.sql