Last active
July 26, 2022 11:55
-
-
Save NileshGule/4c09b06fb071891dce061b8f350dfa84 to your computer and use it in GitHub Desktop.
docker-sql-2017
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
adding dockerfile with sql-server-linux:2017-latest which initializes the database