summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAmir Zarrinkafsh <nightah@me.com>2020-11-11 15:22:09 +1100
committerGitHub <noreply@github.com>2020-11-11 15:22:09 +1100
commit423cd09f26da0a5d5fbd3fd00fe0b082f96e97e9 (patch)
tree1f10df29c8387204b78618f27abaf886960eeb66
parent2834f3f8e88439a7f758dcddda8f87a4c1c61e59 (diff)
[BUGFIX] Dynamically determine healthcheck URL (#1444)
-rw-r--r--Dockerfile4
-rw-r--r--Dockerfile.arm32v74
-rw-r--r--Dockerfile.arm64v84
-rwxr-xr-xentrypoint.sh2
-rwxr-xr-xhealthcheck.sh17
5 files changed, 24 insertions, 7 deletions
diff --git a/Dockerfile b/Dockerfile
index faf50a37c..1a612b9a8 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 5bc09a3a9..8097f497c 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 a905c99b9..92bae683c 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 be58773f8..f331a2209 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 000000000..ab3169af1
--- /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