-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[DOP-15547] Use official MSSQL docker image
- Loading branch information
Showing
8 changed files
with
88 additions
and
24 deletions.
There are no files selected for viewing
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#!/bin/bash | ||
set -o pipefail | ||
|
||
# Wait 60 seconds for SQL Server to start up by ensuring that | ||
# calling SQLCMD does not return an error code, which will ensure that sqlcmd is accessible | ||
# and that system and user databases return "0" which means all databases are in an "online" state | ||
# https://docs.microsoft.com/en-us/sql/relational-databases/system-catalog-views/sys-databases-transact-sql?view=sql-server-2017 | ||
|
||
declare DBSTATUS | ||
declare ERRCODE | ||
TIMEOUT=60 | ||
START=$(date +%s) | ||
echo "Configure DB script started at $(date)" | ||
|
||
while true; do | ||
DELTA=$(($(date +%s) - START)) | ||
if [[ $DELTA -gt $TIMEOUT ]]; then | ||
echo "ERROR: SQL Server took more than ${TIMEOUT} seconds to START up or one or more databases are not in an ONLINE state" | ||
exit 1 | ||
fi | ||
|
||
DBSTATUS=$(/opt/mssql-tools/bin/sqlcmd -h -1 -t 1 -U sa -P ${MSSQL_SA_PASSWORD} -Q "SET NOCOUNT ON; Select SUM(state) from sys.databases" 2>/dev/null | sed -e 's/^[[:space:]]*//') | ||
ERRCODE=$? | ||
if [[ "$DBSTATUS" -eq "0" && "$ERRCODE" -eq "0" ]]; then | ||
echo "INFO: Database ready." | ||
break | ||
else | ||
echo "INFO: Waiting for database to be ready..." | ||
sleep 1 | ||
fi | ||
done | ||
|
||
# Run the setup script to create the DB and the schema in the DB | ||
echo "Running setup.sql"; | ||
/opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P $MSSQL_SA_PASSWORD -d master -i /usr/config/setup.sql; | ||
echo "Success"; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/bin/bash | ||
|
||
# Start the script to create the DB and user | ||
/usr/config/configure-db.sh & | ||
|
||
# Start SQL Server | ||
/opt/mssql/bin/sqlservr |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* | ||
Enter custom T-SQL here that would run after SQL Server has started up. | ||
*/ | ||
|
||
CREATE DATABASE onetl; | ||
GO | ||
|
||
USE onetl; | ||
GO | ||
|
||
CREATE LOGIN onetl WITH PASSWORD = '7ellowEl7akey'; | ||
GO | ||
|
||
CREATE USER onetl FOR LOGIN onetl; | ||
GO | ||
|
||
GRANT CONTROL ON DATABASE::onetl TO onetl; | ||
GO |