Repository navigation
Expand file tree
/
Copy pathmssql
More file actions
46 lines (37 loc) · 1.34 KB
/
Copy pathmssql
File metadata and controls
46 lines (37 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
### This file is not meant to be run directly, but to be sourced from
### the dev script. It defines all the functions required to run an
### MSSQL docker container.
######################
# Configuration #
######################
if [ "$MODE" = "test" ]; then
MSSQL_PORT=31433
else
MSSQL_PORT=21433
fi
MSSQL_PASSWORD=hasuraMSSQL1
MSSQL_CONTAINER_NAME="hasura-dev-mssql-$MSSQL_PORT"
MSSQL_DB_URL="DRIVER={ODBC Driver 17 for SQL Server};SERVER=127.0.0.1,$MSSQL_PORT;Uid=sa;Pwd=$MSSQL_PASSWORD;"
MSSQL_DOCKER="docker exec -it $MSSQL_CONTAINER_NAME sqlcmd -S localhost -U sa -P $MSSQL_PASSWORD"
######################
# Functions #
######################
function mssql_launch_container(){
echo_pretty "Launching MSSQL container: $MSSQL_CONTAINER_NAME"
docker run --name $MSSQL_CONTAINER_NAME \
-p 127.0.0.1:"$MSSQL_PORT":1433 -d hasura/mssql-server-2019-cu10-ubuntu-20.04
}
function mssql_wait {
echo -n "Waiting for mssql to come up"
until ( $MSSQL_DOCKER -Q 'SELECT 1' ) &>/dev/null; do
echo -n '.' && sleep 0.2
done
echo " Ok"
}
function mssql_cleanup(){
echo_pretty "Removing $MSSQL_CONTAINER_NAME and its volumes in 5 seconds!"
echo_pretty " PRESS CTRL-C TO ABORT removal of all containers, or ENTER to clean up right away"
read -t5 || true
docker stop "$MSSQL_CONTAINER_NAME"
docker rm -v "$MSSQL_CONTAINER_NAME"
}