Skip to content

Instantly share code, notes, and snippets.

@NileshGule
Last active July 26, 2022 11:55
Show Gist options
  • Save NileshGule/4c09b06fb071891dce061b8f350dfa84 to your computer and use it in GitHub Desktop.
Save NileshGule/4c09b06fb071891dce061b8f350dfa84 to your computer and use it in GitHub Desktop.
docker-sql-2017
FROM microsoft/mssql-server-linux:2017-latest
ENV ACCEPT_EULA=Y
ENV SA_PASSWORD=January2018
ENV MSSQL_PID=Developer
WORKDIR /src
COPY initialize-database.sql ./
COPY setup-database.sh ./
COPY entrypoint.sh ./
# Grant permissions for the setup-database and entrypoint shell scripts to be executable
RUN chmod +x ./setup-database.sh
RUN chmod +x ./entrypoint.sh
CMD bash ./entrypoint.sh
#start SQL Server, start the script to create the DB and initial data
echo 'starting database setup'
/opt/mssql/bin/sqlservr & ./setup-database.sh & bash
CREATE DATABASE TechTalksDB
GO
SELECT Name from sys.Databases
GO
USE TechTalksDB
GO
CREATE TABLE Categories (id INT, categoryName NVARCHAR(50), description NVARCHAR(100))
GO
INSERT INTO Categories VALUES(1, 'Meetup', 'Community event organized via meetup');
INSERT INTO Categories VALUES(2, 'Conference', 'Tech Conference');
GO
CREATE TABLE TechTalk (id INT, name NVARCHAR(50), category INT)
GO
INSERT INTO TechTalk VALUES (1, 'Scaling Docker Containers', 1);
INSERT INTO TechTalk VALUES (2, 'Azure Container Services', 2);
GO
CREATE TABLE KeyValue ([Key] NVARCHAR(10), [Value] NVARCHAR(100))
GO
INSERT INTO KeyValue VALUES('GoT', 'American fantasy drama television series');
INSERT INTO KeyValue VALUES('MS', 'Microsoft');
INSERT INTO KeyValue VALUES('OS', 'Open source');
INSERT INTO KeyValue VALUES('Doc', 'Doc-chain aka Blockchain');
INSERT INTO KeyValue VALUES('AZ', 'Azure');
INSERT INTO KeyValue VALUES('ACS', 'Azure Container Service');
GO
echo 'Please wait while SQL Server 2017 warms up'
sleep 10s
echo 'Initializing database after 10 seconds of wait'
/opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P January2018 -d master -i initialize-database.sql
echo 'Finished initializing the database'
@NileshGule
Copy link
Author

adding dockerfile with sql-server-linux:2017-latest which initializes the database

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment