From 2052080d7d8a213064910cac491ec5cf9057610e Mon Sep 17 00:00:00 2001 From: Ben Banfield-Zanin Date: Tue, 11 Mar 2025 18:04:33 +0000 Subject: [PATCH] Fix Docker Healthcheck (#29471) * Correct test for docker container being healthy * Correct docker healthcheck for busybox wget * Repeatedly check the health state of the docker container * Use until loop & rely on timeout-minutes * Fix check to look at healthy state --------- Co-authored-by: Michael Telatynski <7t3chguy@gmail.com> --- .github/workflows/docker.yaml | 5 ++++- Dockerfile | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml index 12ebaddf5b..7e5da929d4 100644 --- a/.github/workflows/docker.yaml +++ b/.github/workflows/docker.yaml @@ -61,6 +61,7 @@ jobs: - name: Test the image env: IMAGEID: ${{ steps.test-build.outputs.imageid }} + timeout-minutes: 2 run: | set -x @@ -86,7 +87,9 @@ jobs: test "$MODULE_0" = "/${MODULE_PATH}" # Check healthcheck - test "$(docker inspect -f {{.State.Running}} $CONTAINER_ID)" == "true" + until test "$(docker inspect -f {{.State.Health.Status}} $CONTAINER_ID)" == "healthy"; do + sleep 1 + done # Clean up docker stop "$CONTAINER_ID" diff --git a/Dockerfile b/Dockerfile index ed1312101e..cd1766347a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -47,4 +47,4 @@ USER nginx # HTTP listen port ENV ELEMENT_WEB_PORT=80 -HEALTHCHECK --start-period=5s CMD wget --retry-connrefused --tries=5 -q --wait=3 --spider http://localhost:$ELEMENT_WEB_PORT/config.json +HEALTHCHECK --start-period=5s CMD wget -q --spider http://localhost:$ELEMENT_WEB_PORT/config.json