Skip to content

Commit

Permalink
Move healthcheck to dockerfile
Browse files Browse the repository at this point in the history
Signed-off-by: John Gomersall <thegoms@gmail.com>
  • Loading branch information
john-gom committed Jun 28, 2024
1 parent 75d87e4 commit db1957e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,7 @@ FROM quay.io/keycloak/keycloak:${KEYCLOAK_VERSION}

COPY --from=keycloak_builder /opt/keycloak/ /opt/keycloak/

HEALTHCHECK --start-period=60s --interval=1s CMD timeout 1s bash -c 'test -f /tmp/health && :> /dev/tcp/localhost/8080'

ENTRYPOINT [ "sh", "/opt/keycloak/startup.sh" ]

3 changes: 0 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,3 @@ services:
- KEYCLOAK_BASE_URL
- KEYCLOAK_REALM_NAME
- KC_SPI_EVENTS_LISTENER_REDIS_EVENT_LISTENER_REDIS_URL=redis://${REDIS_URL}/0
healthcheck:
test: timeout 10s bash -c ':> /dev/tcp/localhost/8080'
start_interval: 10s
5 changes: 5 additions & 0 deletions runtime-scripts/after_startup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ function wait_for_keycloak() {
echo "Keycloak is now up and running."
}

# Docker healthcheck waits for this file to appear and for port to be open
rm -f /tmp/health

# Waiting for Keycloak to start before proceeding with the configurations.
wait_for_keycloak

Expand All @@ -33,3 +36,5 @@ echo "Calling configure_keycloak"
/opt/keycloak/bin/kcadm.sh update realms/open-products-facts -f /opt/keycloak/realm_settings.json
/opt/keycloak/bin/kcadm.sh update users/profile -f /opt/keycloak/users_profile.json -r open-products-facts
echo "End of configure_keycloak"

echo Healthy > /tmp/health

0 comments on commit db1957e

Please sign in to comment.