add mssql
This commit is contained in:
3
db/mssql/Dockerfile
Normal file
3
db/mssql/Dockerfile
Normal 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
3
db/mssql/entrypoint.sh
Executable 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
27
db/mssql/init.sql
Normal 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
7
db/mssql/run-initialization.sh
Executable 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
|
||||
Reference in New Issue
Block a user