Struggling to configure a health check in Github workflows.
The container is jboss/keycloak:12.0.4
.
Workflow is this:
jobs:
test:
name: Test
runs-on: ubuntu-latest
services:
keycloak:
image: jboss/keycloak:12.0.4
options: --name keycloak
steps:
...
The container needs around 30-40s to become healthy. I tried two approaches without success.
- Services options:
options: --health-cmd curl "http://localhost:8080/auth/realms/master" --health-interval 30s
This worked locally but in the workflow it seems that Github is failing before docker has completed the health check. No matter what values I set for health-interval
, Github tries 4 times (not in the interval I passed), then fails.
- Hack a healthcheck step:
steps:
- name: Healthcheck
continue-on-error: true
run: |
echo "HEALTHCHECK, BECAUSE"
docker exec keycloak curl -s --fail "http://localhost:8080/auth/realms/master" 1>/dev/null
while [ "$?" != "0" ]; do
docker exec keycloak curl -s --fail "http://localhost:8080/auth/realms/master" 1>/dev/null
sleep 10s
done
This looks bad and doesn't work either. The step is set as continue-on-error
, but this doesn't mean the step itself goes past the first docker exec
statement.
So any ideas on how to solve this?