From 1edb422f3d5922dd0e9cc684e03ae42c9e88e780 Mon Sep 17 00:00:00 2001 From: Zoey Date: Thu, 25 Aug 2022 15:06:23 +0200 Subject: [PATCH] add docker healthchecks to the docker images Signed-off-by: Zoey --- Containers/apache/Dockerfile | 5 ++++- Containers/collabora/Dockerfile | 2 ++ Containers/domaincheck/Dockerfile | 4 +++- Containers/imaginary/Dockerfile | 13 +++++++++++++ Containers/mastercontainer/Dockerfile | 2 ++ Containers/nextcloud/Dockerfile | 2 ++ Containers/onlyoffice/Dockerfile | 2 ++ Containers/postgresql/Dockerfile | 2 ++ Containers/redis/Dockerfile | 2 ++ Containers/talk/Dockerfile | 3 +++ 10 files changed, 35 insertions(+), 2 deletions(-) diff --git a/Containers/apache/Dockerfile b/Containers/apache/Dockerfile index c0de61ba..42db9cb5 100644 --- a/Containers/apache/Dockerfile +++ b/Containers/apache/Dockerfile @@ -19,6 +19,7 @@ RUN set -ex; \ openssl \ netcat \ dpkg-dev \ + curl \ ; \ rm -rf /var/lib/apt/lists/* @@ -72,4 +73,6 @@ RUN echo "root:$(openssl rand -base64 12)" | chpasswd USER www-data ENTRYPOINT ["start.sh"] -CMD ["/usr/bin/supervisord", "-c", "/supervisord.conf"] \ No newline at end of file +CMD ["/usr/bin/supervisord", "-c", "/supervisord.conf"] + +HEALTHCHECK CMD (curl -skfI localhost:8000 && curl -skfI localhost:$APACHE_PORT) || exit 1 \ No newline at end of file diff --git a/Containers/collabora/Dockerfile b/Containers/collabora/Dockerfile index 9a63451d..0873e2dc 100644 --- a/Containers/collabora/Dockerfile +++ b/Containers/collabora/Dockerfile @@ -13,3 +13,5 @@ RUN set -ex; \ rm -rf /var/lib/apt/lists/* USER 104 + +HEALTHCHECK CMD curl -skfI localhost:9980 || exit 1 diff --git a/Containers/domaincheck/Dockerfile b/Containers/domaincheck/Dockerfile index b147cd97..ab09e156 100644 --- a/Containers/domaincheck/Dockerfile +++ b/Containers/domaincheck/Dockerfile @@ -1,5 +1,5 @@ FROM alpine:3.16.2 -RUN apk add --update --no-cache lighttpd bash +RUN apk add --update --no-cache lighttpd bash curl RUN adduser -S www-data -G www-data RUN rm -rf /etc/lighttpd/lighttpd.conf @@ -14,3 +14,5 @@ RUN chmod +x /start.sh USER www-data RUN mkdir -p /var/www/domaincheck/ ENTRYPOINT ["/start.sh"] + +HEALTHCHECK CMD curl -skfI localhost:$APACHE_PORT || exit 1 \ No newline at end of file diff --git a/Containers/imaginary/Dockerfile b/Containers/imaginary/Dockerfile index a890c534..af0347b8 100644 --- a/Containers/imaginary/Dockerfile +++ b/Containers/imaginary/Dockerfile @@ -1,2 +1,15 @@ # From https://github.com/h2non/imaginary/blob/master/Dockerfile FROM nextcloud/imaginary:20220822 + +USER root +RUN set -ex; \ + \ + apt-get update; \ + apt-get install -y --no-install-recommends \ + ca-certificates \ + curl \ + ; \ + rm -rf /var/lib/apt/lists/* +USER nobody + +HEALTHCHECK CMD curl -skI 127.0.0.1:9000 || exit 1 \ No newline at end of file diff --git a/Containers/mastercontainer/Dockerfile b/Containers/mastercontainer/Dockerfile index 339a8715..37442eb2 100644 --- a/Containers/mastercontainer/Dockerfile +++ b/Containers/mastercontainer/Dockerfile @@ -101,3 +101,5 @@ USER root ENTRYPOINT ["start.sh"] CMD ["/usr/bin/supervisord", "-c", "/supervisord.conf"] + +HEALTHCHECK CMD curl -skfI https://localhost:8080 || exit 1 \ No newline at end of file diff --git a/Containers/nextcloud/Dockerfile b/Containers/nextcloud/Dockerfile index 5c926a54..e2aa264b 100644 --- a/Containers/nextcloud/Dockerfile +++ b/Containers/nextcloud/Dockerfile @@ -252,3 +252,5 @@ RUN echo "root:$(openssl rand -base64 12)" | chpasswd USER www-data ENTRYPOINT ["/start.sh"] + +HEALTHCHECK CMD (nc -z localhost 9000 && curl -skI localhost:7867) || exit 1 \ No newline at end of file diff --git a/Containers/onlyoffice/Dockerfile b/Containers/onlyoffice/Dockerfile index e0b26f5b..6be6b60e 100644 --- a/Containers/onlyoffice/Dockerfile +++ b/Containers/onlyoffice/Dockerfile @@ -1,2 +1,4 @@ # From https://github.com/ONLYOFFICE/Docker-DocumentServer/blob/master/Dockerfile FROM onlyoffice/documentserver:7.1.1.23 + +HEALTHCHECK CMD curl -skfI localhost || exit 1 \ No newline at end of file diff --git a/Containers/postgresql/Dockerfile b/Containers/postgresql/Dockerfile index c6cefa1d..ea83de61 100644 --- a/Containers/postgresql/Dockerfile +++ b/Containers/postgresql/Dockerfile @@ -31,3 +31,5 @@ RUN echo "root:$(openssl rand -base64 12)" | chpasswd USER postgres ENTRYPOINT ["start.sh"] + +HEALTHCHECK CMD psql -d "postgresql://$POSTGRES_USER:$POSTGRES_PASSWORD@localhost:5432/$POSTGRES_DB" -c "select now()" || exit 1 \ No newline at end of file diff --git a/Containers/redis/Dockerfile b/Containers/redis/Dockerfile index 4c3d957a..620f3739 100644 --- a/Containers/redis/Dockerfile +++ b/Containers/redis/Dockerfile @@ -11,3 +11,5 @@ RUN echo "root:$(openssl rand -base64 12)" | chpasswd USER redis ENTRYPOINT ["start.sh"] + +HEALTHCHECK CMD redis-cli -a $REDIS_HOST_PASSWORD PING || exit 1 \ No newline at end of file diff --git a/Containers/talk/Dockerfile b/Containers/talk/Dockerfile index 4bf84f6d..6b666374 100644 --- a/Containers/talk/Dockerfile +++ b/Containers/talk/Dockerfile @@ -9,6 +9,7 @@ RUN set -ex; \ supervisor \ curl \ ca-certificates \ + netcat \ ; \ rm -rf /var/lib/apt/lists/* @@ -67,3 +68,5 @@ ENV TALK_PORT=3478 USER talk ENTRYPOINT ["start.sh"] CMD ["/usr/bin/supervisord", "-c", "/supervisord.conf"] + +HEALTHCHECK CMD (curl -skI localhost:8081 && curl -skI localhost:8188 && curl -skf --http0.9 localhost:4222 && nc -z localhost $TALK_PORT) || exit 1 \ No newline at end of file