summaryrefslogtreecommitdiff
path: root/docker
diff options
context:
space:
mode:
authorTimo Kösters <timo@koesters.xyz>2021-08-31 16:59:33 +0000
committerTimo Kösters <timo@koesters.xyz>2021-08-31 16:59:33 +0000
commitec384116202fafd457184098afd485b5b833064d (patch)
treed382af921aba2d007ab33780057ddf49e0d47e16 /docker
parent49dd3567c693df48cfb4ca5ae482b5607e684efa (diff)
parenta08ea1569599fa12e31f1ac45bc24374cf9dacaf (diff)
downloadconduit-ec384116202fafd457184098afd485b5b833064d.zip
Merge branch 'health_script' into 'master'
Move docker healthcheck into dedicated script. See merge request famedly/conduit!173
Diffstat (limited to 'docker')
-rw-r--r--docker/ci-binaries-packaging.Dockerfile6
-rw-r--r--docker/healthcheck.sh13
2 files changed, 15 insertions, 4 deletions
diff --git a/docker/ci-binaries-packaging.Dockerfile b/docker/ci-binaries-packaging.Dockerfile
index 797ef0c..1fe85bf 100644
--- a/docker/ci-binaries-packaging.Dockerfile
+++ b/docker/ci-binaries-packaging.Dockerfile
@@ -53,10 +53,7 @@ RUN apk add --no-cache \
libgcc
# Test if Conduit is still alive, uses the same endpoint as Element
-HEALTHCHECK --start-period=5s \
- CMD curl --fail -s "http://localhost:$(grep -m1 -o 'port\s=\s[0-9]*' conduit.toml | grep -m1 -o '[0-9]*')/_matrix/client/versions" || \
- curl -k --fail -s "https://localhost:$(grep -m1 -o 'port\s=\s[0-9]*' conduit.toml | grep -m1 -o '[0-9]*')/_matrix/client/versions" || \
- exit 1
+HEALTHCHECK --start-period=5s --interval=60s CMD ./healthcheck.sh
# Set user to www-data
USER www-data
@@ -68,3 +65,4 @@ ENTRYPOINT [ "/srv/conduit/conduit" ]
# Copy the Conduit binary into the image at the latest possible moment to maximise caching:
COPY ./conduit-x86_64-unknown-linux-musl /srv/conduit/conduit
+COPY ./docker/healthcheck.sh /srv/conduit/
diff --git a/docker/healthcheck.sh b/docker/healthcheck.sh
new file mode 100644
index 0000000..568838e
--- /dev/null
+++ b/docker/healthcheck.sh
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+# If the port is not specified as env var, take it from the config file
+if [ -z ${CONDUIT_PORT} ]; then
+ CONDUIT_PORT=$(grep -m1 -o 'port\s=\s[0-9]*' conduit.toml | grep -m1 -o '[0-9]*')
+fi
+
+# The actual health check.
+# We try to first get a response on HTTP and when that fails on HTTPS and when that fails, we exit with code 1.
+# TODO: Change this to a single curl call. Do we have a config value that we can check for that?
+curl --fail -s "http://localhost:${CONDUIT_PORT}/_matrix/client/versions" || \
+ curl -k --fail -s "https://localhost:${CONDUIT_PORT}/_matrix/client/versions" || \
+ exit 1