Skip to content

Commit 2052080

Browse files
benbzt3chguy
andauthored
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 <[email protected]>
1 parent cc95d15 commit 2052080

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

.github/workflows/docker.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ jobs:
6161
- name: Test the image
6262
env:
6363
IMAGEID: ${{ steps.test-build.outputs.imageid }}
64+
timeout-minutes: 2
6465
run: |
6566
set -x
6667
@@ -86,7 +87,9 @@ jobs:
8687
test "$MODULE_0" = "/${MODULE_PATH}"
8788
8889
# Check healthcheck
89-
test "$(docker inspect -f {{.State.Running}} $CONTAINER_ID)" == "true"
90+
until test "$(docker inspect -f {{.State.Health.Status}} $CONTAINER_ID)" == "healthy"; do
91+
sleep 1
92+
done
9093
9194
# Clean up
9295
docker stop "$CONTAINER_ID"

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,4 @@ USER nginx
4747
# HTTP listen port
4848
ENV ELEMENT_WEB_PORT=80
4949

50-
HEALTHCHECK --start-period=5s CMD wget --retry-connrefused --tries=5 -q --wait=3 --spider http://localhost:$ELEMENT_WEB_PORT/config.json
50+
HEALTHCHECK --start-period=5s CMD wget -q --spider http://localhost:$ELEMENT_WEB_PORT/config.json

0 commit comments

Comments
 (0)