From ac92643212c2ca6a19be1bede3f6af7c405226e8 Mon Sep 17 00:00:00 2001 From: Amir Zarrinkafsh Date: Wed, 3 Feb 2021 10:17:46 +1100 Subject: [PATCH] test(handlers): add health check to coverage build (#1684) * test(handlers): add health check to coverage build This change ensures that the integration test container also utilises the health check script to ensure coverage for this area of code. * update health check script for coverage container * remove start period and ignore cert check --- Dockerfile.coverage | 2 ++ healthcheck.sh | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Dockerfile.coverage b/Dockerfile.coverage index f05a0bee5..a4d3799c8 100644 --- a/Dockerfile.coverage +++ b/Dockerfile.coverage @@ -57,6 +57,7 @@ RUN apk --no-cache add ca-certificates tzdata WORKDIR /app COPY --from=builder-backend /go/src/app/cmd/authelia/authelia ./ +COPY healthcheck.sh /usr/local/bin/ EXPOSE 9091 @@ -65,3 +66,4 @@ VOLUME /config ENV PATH="/app:${PATH}" CMD ["authelia", "-test.coverprofile=/authelia/coverage.txt", "COVERAGE", "--config", "/config/configuration.yml"] +HEALTHCHECK --interval=30s --timeout=3s CMD /usr/local/bin/healthcheck.sh diff --git a/healthcheck.sh b/healthcheck.sh index f4a089374..147e18d74 100755 --- a/healthcheck.sh +++ b/healthcheck.sh @@ -1,6 +1,6 @@ #!/bin/sh -AUTHELIA_CONFIG=$(pgrep -af authelia | awk '{print $4}') +AUTHELIA_CONFIG=$(pgrep -af authelia | awk '{print $NF}') AUTHELIA_SCHEME=$(grep ^tls "${AUTHELIA_CONFIG}") AUTHELIA_HOST=$(grep ^host "${AUTHELIA_CONFIG}" | sed -e 's/host: //' -e 's/\r//') AUTHELIA_PORT=$(grep ^port "${AUTHELIA_CONFIG}" | sed -e 's/port: //' -e 's/\r//') @@ -20,4 +20,4 @@ if [ -z "${AUTHELIA_PORT}" ]; then AUTHELIA_PORT=9091 fi -wget --quiet --tries=1 --spider "${AUTHELIA_SCHEME}://${AUTHELIA_HOST}:${AUTHELIA_PORT}${AUTHELIA_PATH}/api/health" || exit 1 +wget --quiet --no-check-certificate --tries=1 --spider "${AUTHELIA_SCHEME}://${AUTHELIA_HOST}:${AUTHELIA_PORT}${AUTHELIA_PATH}/api/health" || exit 1