[BUGFIX] Dynamically determine healthcheck URL (#1444)

pull/1438/head^2
Amir Zarrinkafsh 2020-11-11 15:22:09 +11:00 committed by GitHub
parent 2834f3f8e8
commit 423cd09f26
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 24 additions and 7 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

17
healthcheck.sh 100755
View File

@ -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