diff --git a/Dockerfile b/Dockerfile index faf50a37..1a612b9a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -56,7 +56,7 @@ WORKDIR /app RUN apk --no-cache add ca-certificates su-exec tzdata COPY --from=builder-backend /go/src/app/cmd/authelia/authelia ./ -COPY ./entrypoint.sh /usr/local/bin/entrypoint.sh +COPY entrypoint.sh healthcheck.sh /usr/local/bin/ EXPOSE 9091 @@ -69,4 +69,4 @@ PGID=0 ENTRYPOINT ["/usr/local/bin/entrypoint.sh"] CMD ["--config", "/config/configuration.yml"] -HEALTHCHECK --interval=30s --timeout=3s CMD wget --quiet --tries=1 --spider http://localhost:9091/api/state || exit 1 +HEALTHCHECK --interval=30s --timeout=3s --start-period=1m CMD /usr/local/bin/healthcheck.sh diff --git a/Dockerfile.arm32v7 b/Dockerfile.arm32v7 index 5bc09a3a..8097f497 100644 --- a/Dockerfile.arm32v7 +++ b/Dockerfile.arm32v7 @@ -62,7 +62,7 @@ RUN apk --no-cache add ca-certificates su-exec tzdata && \ rm /usr/bin/qemu-arm-static COPY --from=builder-backend /go/src/app/cmd/authelia/authelia ./ -COPY ./entrypoint.sh /usr/local/bin/entrypoint.sh +COPY entrypoint.sh healthcheck.sh /usr/local/bin/ EXPOSE 9091 @@ -75,4 +75,4 @@ PGID=0 ENTRYPOINT ["/usr/local/bin/entrypoint.sh"] CMD ["--config", "/config/configuration.yml"] -HEALTHCHECK --interval=30s --timeout=3s CMD wget --quiet --tries=1 --spider http://localhost:9091/api/state || exit 1 +HEALTHCHECK --interval=30s --timeout=3s --start-period=1m CMD /usr/local/bin/healthcheck.sh diff --git a/Dockerfile.arm64v8 b/Dockerfile.arm64v8 index a905c99b..92bae683 100644 --- a/Dockerfile.arm64v8 +++ b/Dockerfile.arm64v8 @@ -62,7 +62,7 @@ RUN apk --no-cache add ca-certificates su-exec tzdata && \ rm /usr/bin/qemu-aarch64-static COPY --from=builder-backend /go/src/app/cmd/authelia/authelia ./ -COPY ./entrypoint.sh /usr/local/bin/entrypoint.sh +COPY entrypoint.sh healthcheck.sh /usr/local/bin/ EXPOSE 9091 @@ -75,4 +75,4 @@ PGID=0 ENTRYPOINT ["/usr/local/bin/entrypoint.sh"] CMD ["--config", "/config/configuration.yml"] -HEALTHCHECK --interval=30s --timeout=3s CMD wget --quiet --tries=1 --spider http://localhost:9091/api/state || exit 1 +HEALTHCHECK --interval=30s --timeout=3s --start-period=1m CMD /usr/local/bin/healthcheck.sh diff --git a/entrypoint.sh b/entrypoint.sh index be58773f..f331a220 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -7,4 +7,4 @@ elif [[ $(id -u) != 0 ]] || [[ $(id -g) != 0 ]]; then else chown -R ${PUID}:${PGID} /config exec su-exec ${PUID}:${PGID} authelia "$@" -fi +fi \ No newline at end of file diff --git a/healthcheck.sh b/healthcheck.sh new file mode 100755 index 00000000..ab3169af --- /dev/null +++ b/healthcheck.sh @@ -0,0 +1,17 @@ +#!/bin/sh + +AUTHELIA_CONFIG=$(ps | grep authelia | awk '{print $6}' | head -1) +AUTHELIA_SCHEME=$(cat "${AUTHELIA_CONFIG}" | grep ^tls) +AUTHELIA_PORT=$(cat "${AUTHELIA_CONFIG}" | grep ^port | sed -e 's/port: //') + +if [[ -z ${AUTHELIA_PORT} ]]; then + AUTHELIA_PORT=9091 +fi + +if [[ -z ${AUTHELIA_SCHEME} ]]; then + AUTHELIA_SCHEME=http +else + AUTHELIA_SCHEME=https +fi + +wget --quiet --tries=1 --spider ${AUTHELIA_SCHEME}://localhost:${AUTHELIA_PORT}/api/state || exit 1 \ No newline at end of file