Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding health check to sqlserver docker-compose and make it start 5 seconds after launching the container #562

Merged
merged 18 commits into from
Oct 4, 2024
15 changes: 8 additions & 7 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -303,16 +303,16 @@ jobs:
distribution: 'temurin'

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{env.PYTHON_VERSION}}
uses: actions/setup-python@v5
with:
python-version: ${{env.PYTHON_VERSION}}

- name: Install Python dependencies
- name: Install Python dependencies
working-directory: ./scripts/anonymization
run: |
if [[ ${{matrix.benchmark}} == anonymization ]]; then
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install -r requirements.txt
else
echo "Dependency installation not necessary for benchmark"
fi
Expand Down Expand Up @@ -635,10 +635,11 @@ jobs:
ACCEPT_EULA: Y
SA_PASSWORD: SApassword1
options: >-
--health-cmd "/opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P SApassword1 -b -Q 'SELECT 1;'"
--health-interval 10s
--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;\"'"
--health-interval 5s
--health-timeout 5s
--health-retries 5
--health-start-period 5s
ports:
- 1433:1433
steps:
Expand Down
6 changes: 6 additions & 0 deletions docker/sqlserver-latest/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ services:
container_name: sqlserver
hostname: sqlserver
image: mcr.microsoft.com/mssql/server:latest
healthcheck:
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;\"'"]
interval: 5s
timeout: 5s
retries: 5
start_period: 5s
environment:
ACCEPT_EULA: Y
SA_PASSWORD: SApassword1
Expand Down
11 changes: 10 additions & 1 deletion docker/sqlserver-latest/up.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,20 @@ cd "$scriptdir/"

docker compose up -d

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

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

# Wait until ready
for i in {1..60}; do
if /usr/bin/docker inspect --format="{{print .State.Health.Status}}" sqlserver | grep -q -x healthy; then
break
else
sleep 5
fi
done

function run_sqlcmd_in_docker() {
set -x
docker run --rm --network=$network --entrypoint /opt/mssql-tools/bin/sqlcmd mcr.microsoft.com/mssql-tools:latest \
Expand Down