Implement Docker health check in CI workflow

Added a health check step for the Docker container in the CI workflow.
This commit is contained in:
Dingedi 2025-12-10 20:50:09 +01:00 committed by GitHub
parent 296e53e511
commit 3ef4361852
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -48,3 +48,21 @@ jobs:
- name: Docker build with some models
run: docker build -f docker/Dockerfile -t libretranslate --build-arg models=en,es .
test_docker_healthcheck:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Docker compose up
run: LT_LOAD_ONLY=en,fr docker compose up -d
- name: Check Healthcheck
run: |
for i in {1..60}; do
STATUS=$(docker inspect -f '{{ .State.Health.Status }}' libretranslate 2>/dev/null || echo 'no')
echo "Status: $STATUS"
if [ "$STATUS" = "healthy" ]; then exit 0; fi
sleep 2
done
echo "LibreTranslate did not become healthy"
exit 1