Skip to content

Commit 903fd00

Browse files
authored
Adding health check to sqlserver docker-compose and make it start 5 seconds after launching the container (#562)
1 parent b8f35bb commit 903fd00

File tree

3 files changed

+24
-8
lines changed

3 files changed

+24
-8
lines changed

.github/workflows/maven.yml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -303,16 +303,16 @@ jobs:
303303
distribution: 'temurin'
304304

305305
- name: Set up Python
306-
uses: actions/setup-python@v5
307-
with:
308-
python-version: ${{env.PYTHON_VERSION}}
306+
uses: actions/setup-python@v5
307+
with:
308+
python-version: ${{env.PYTHON_VERSION}}
309309

310-
- name: Install Python dependencies
310+
- name: Install Python dependencies
311311
working-directory: ./scripts/anonymization
312312
run: |
313313
if [[ ${{matrix.benchmark}} == anonymization ]]; then
314314
python -m pip install --upgrade pip
315-
pip install -r requirements.txt
315+
pip install -r requirements.txt
316316
else
317317
echo "Dependency installation not necessary for benchmark"
318318
fi
@@ -635,10 +635,11 @@ jobs:
635635
ACCEPT_EULA: Y
636636
SA_PASSWORD: SApassword1
637637
options: >-
638-
--health-cmd "/opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P SApassword1 -b -Q 'SELECT 1;'"
639-
--health-interval 10s
638+
--health-cmd="find /opt/mssql-tools*/bin/ -name sqlcmd -executable -print -quit | xargs -t -I% sh -c '% -C -S localhost -U sa -P SApassword1 -b -Q \"SELECT 1;\"'"
639+
--health-interval 5s
640640
--health-timeout 5s
641641
--health-retries 5
642+
--health-start-period 5s
642643
ports:
643644
- 1433:1433
644645
steps:

docker/sqlserver-latest/docker-compose.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ services:
66
container_name: sqlserver
77
hostname: sqlserver
88
image: mcr.microsoft.com/mssql/server:latest
9+
healthcheck:
10+
test: ["CMD-SHELL", "find /opt/mssql-tools*/bin/ -name sqlcmd -executable -print -quit | xargs -t -I% sh -c '% -C -S localhost -U sa -P SApassword1 -b -Q \"SELECT 1;\"'"]
11+
interval: 5s
12+
timeout: 5s
13+
retries: 5
14+
start_period: 5s
915
environment:
1016
ACCEPT_EULA: Y
1117
SA_PASSWORD: SApassword1

docker/sqlserver-latest/up.sh

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,20 @@ cd "$scriptdir/"
66

77
docker compose up -d
88

9-
network=$(docker ps --format "{{.Names}} {{.Networks}}" | awk '( $1 ~ /^'$BENCHBASE_PROFILE'/ ) { print $2 }')
9+
network=$(docker ps --format "{{.Names}} {{.Networks}}" | awk '( $1 ~ /^sqlserver/ ) { print $2 }')
1010

1111
# Also setup the database for use with the sample configs.
1212
# See Also: .github/workflows/maven.yml
1313

14+
# Wait until ready
15+
for i in {1..60}; do
16+
if /usr/bin/docker inspect --format="{{print .State.Health.Status}}" sqlserver | grep -q -x healthy; then
17+
break
18+
else
19+
sleep 5
20+
fi
21+
done
22+
1423
function run_sqlcmd_in_docker() {
1524
set -x
1625
docker run --rm --network=$network --entrypoint /opt/mssql-tools/bin/sqlcmd mcr.microsoft.com/mssql-tools:latest \

0 commit comments

Comments
 (0)