From 2145df0dfb35276edba0e04ba7d3b52cf5efeaea Mon Sep 17 00:00:00 2001 From: Jamie Curnow Date: Wed, 13 Nov 2024 10:28:02 +1000 Subject: [PATCH] Use docker healthcheck for authentik --- scripts/ci/fulltest-cypress | 2 +- scripts/wait-healthy | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/scripts/ci/fulltest-cypress b/scripts/ci/fulltest-cypress index 8ef38c4f..c4a0844f 100755 --- a/scripts/ci/fulltest-cypress +++ b/scripts/ci/fulltest-cypress @@ -79,7 +79,7 @@ bash "$DIR/../wait-healthy" "$(docker-compose ps --all -q fullstack)" 120 # Wait for authentik to be healthy, if it exists as a compose service if [ "$(docker-compose ps --all -q authentik)" != "" ]; then - bash "$DIR/../wait-healthy" "$(docker-compose ps --all -q authentik)" 90 + bash "$DIR/../wait-healthy" "$(docker-compose ps --all -q authentik)" 90 'true' fi # Run tests diff --git a/scripts/wait-healthy b/scripts/wait-healthy index a07da007..8fc3d9b0 100755 --- a/scripts/wait-healthy +++ b/scripts/wait-healthy @@ -5,17 +5,24 @@ DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" if [ "$1" == "" ]; then echo "Waits for a docker container to be healthy." - echo "Usage: $0 docker-container 30" + echo " Usage: $0 docker-container 30" + echo "or use the third parameter to use the docker healthcheck instead of the internal one." + echo " Usage: $0 docker-container 30 true" exit 1 fi SERVICE=$1 LIMIT=${2:-90} +USE_DOCKER_HEALTHCHECK=${3:-false} echo -e "${BLUE}❯ ${CYAN}Waiting for healthy: ${YELLOW}${SERVICE}${RESET}" is_up() { - docker exec "$SERVICE" /bin/healthcheck.sh + if [ "$USE_DOCKER_HEALTHCHECK" == "true" ]; then + docker inspect --format='{{.State.Health.Status}}' "$SERVICE" | grep -qi "healthy" + else + docker exec "$SERVICE" /bin/healthcheck.sh + fi } i=0