Skip to content

Commit

Permalink
Merge pull request #5689 from nextcloud/enh/noid/add-healthcheck
Browse files Browse the repository at this point in the history
containers-schema.json: add healtchecks
  • Loading branch information
szaimen authored Dec 3, 2024
2 parents 478c25e + e072d07 commit 9341392
Show file tree
Hide file tree
Showing 18 changed files with 188 additions and 8 deletions.
4 changes: 3 additions & 1 deletion Containers/collabora/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ RUN set -ex; \
; \
rm -rf /var/lib/apt/lists/*;

COPY --chmod=775 healthcheck.sh /healthcheck.sh

USER 100

HEALTHCHECK CMD nc -z 127.0.0.1 9980 || exit 1
HEALTHCHECK --start-period=360s CMD /healthcheck.sh
LABEL com.centurylinklabs.watchtower.enable="false"
3 changes: 3 additions & 0 deletions Containers/collabora/healthcheck.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

nc -z 127.0.0.1 9980 || exit 1
4 changes: 3 additions & 1 deletion Containers/fulltextsearch/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ RUN set -ex; \
; \
rm -rf /var/lib/apt/lists/*;

COPY --chmod=775 healthcheck.sh /healthcheck.sh

USER 1000:0

HEALTHCHECK CMD nc -z 127.0.0.1 9200 || exit 1
HEALTHCHECK --interval=10s --timeout=5s --start-period=1m --retries=5 CMD /healthcheck.sh
LABEL com.centurylinklabs.watchtower.enable="false"
3 changes: 3 additions & 0 deletions Containers/fulltextsearch/healthcheck.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

nc -z 127.0.0.1 9200 || exit 1
5 changes: 3 additions & 2 deletions Containers/imaginary/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# syntax=docker/dockerfile:latest
FROM golang:1.23.3-alpine3.20 AS go

ENV IMAGINARY_HASH=8f36a26c448be8c151a3878404b75fcd1cd3cf0c
ENV IMAGINARY_HASH=8f36a26c448be8c151a3878404b75fcd1cd3cf0c

RUN set -ex; \
apk add --no-cache \
Expand Down Expand Up @@ -30,6 +30,7 @@ RUN set -ex; \

COPY --from=go /go/bin/imaginary /usr/local/bin/imaginary
COPY --chmod=775 start.sh /start.sh
COPY --chmod=775 healthcheck.sh /healthcheck.sh

ENV PORT=9000

Expand All @@ -39,5 +40,5 @@ USER 65534
ENV MALLOC_ARENA_MAX=2
ENTRYPOINT ["/start.sh"]

HEALTHCHECK CMD nc -z 127.0.0.1 "$PORT" || exit 1
HEALTHCHECK CMD /healthcheck.sh
LABEL com.centurylinklabs.watchtower.enable="false"
3 changes: 3 additions & 0 deletions Containers/imaginary/healthcheck.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

nc -z 127.0.0.1 "$PORT" || exit 1
2 changes: 1 addition & 1 deletion Containers/nextcloud/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -279,5 +279,5 @@ USER root
ENTRYPOINT ["/start.sh"]
CMD ["/usr/bin/supervisord", "-c", "/supervisord.conf"]

HEALTHCHECK --start-period=60s CMD sudo -E -u www-data bash /healthcheck.sh
HEALTHCHECK CMD /healthcheck.sh
LABEL com.centurylinklabs.watchtower.enable="false"
4 changes: 3 additions & 1 deletion Containers/onlyoffice/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,7 @@ FROM onlyoffice/documentserver:8.2.2.1

# USER root is probably used

HEALTHCHECK CMD nc -z 127.0.0.1 80 || exit 1
COPY --chmod=775 healthcheck.sh /healthcheck.sh

HEALTHCHECK --start-period=360s CMD /healthcheck.sh
LABEL com.centurylinklabs.watchtower.enable="false"
3 changes: 3 additions & 0 deletions Containers/onlyoffice/healthcheck.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

nc -z 127.0.0.1 80 || exit 1
4 changes: 3 additions & 1 deletion Containers/redis/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ RUN set -ex; \
# Get rid of unused binaries
rm -f /usr/local/bin/gosu;

COPY --chmod=775 healthcheck.sh /healthcheck.sh

USER 999
ENTRYPOINT ["/start.sh"]

HEALTHCHECK CMD redis-cli -a $REDIS_HOST_PASSWORD PING || exit 1
HEALTHCHECK CMD /healthcheck.sh
LABEL com.centurylinklabs.watchtower.enable="false"
3 changes: 3 additions & 0 deletions Containers/redis/healthcheck.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

redis-cli -a "$REDIS_HOST_PASSWORD" PING || exit 1
3 changes: 2 additions & 1 deletion Containers/talk-recording/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
FROM python:3.13.0-alpine3.20

COPY --chmod=775 start.sh /start.sh
COPY --chmod=775 healthcheck.sh /healthcheck.sh

ENV RECORDING_VERSION=v0.1
ENV ALLOW_ALL=false
Expand Down Expand Up @@ -54,5 +55,5 @@ USER 122
ENTRYPOINT ["/start.sh"]
CMD ["python", "-m", "nextcloud.talk.recording", "--config", "/conf/recording.conf"]

HEALTHCHECK CMD nc -z 127.0.0.1 1234 || exit 1
HEALTHCHECK CMD /healthcheck.sh
LABEL com.centurylinklabs.watchtower.enable="false"
3 changes: 3 additions & 0 deletions Containers/talk-recording/healthcheck.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

nc -z 127.0.0.1 1234 || exit 1
4 changes: 4 additions & 0 deletions Containers/whiteboard/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# syntax=docker/dockerfile:latest
# Probably from this file: https://github.com/nextcloud/whiteboard/blob/main/Dockerfile
FROM ghcr.io/nextcloud-releases/whiteboard:v1.0.4

USER root
Expand All @@ -8,6 +9,9 @@ RUN set -ex; \
USER 65534

COPY --chmod=775 start.sh /start.sh
COPY --chmod=775 healthcheck.sh /healthcheck.sh

HEALTHCHECK CMD /healthcheck.sh

ENTRYPOINT ["/start.sh"]

Expand Down
4 changes: 4 additions & 0 deletions Containers/whiteboard/healthcheck.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash

nc -z "$REDIS_HOST" 6379 || exit 0
nc -z 127.0.0.1 3002 || exit 1
10 changes: 10 additions & 0 deletions nextcloud-aio-helm-chart/update-helm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ set -ex
cd manual-install
cp latest.yml latest.yml.backup

# Additional config
# shellcheck disable=SC1083
sed -i -E '/^( *- )(NET_RAW|SYS_NICE|MKNOD|SYS_ADMIN)$/!s/( *- )([A-Z_]+)$/\1\2=${\2}/' latest.yml
cp sample.conf /tmp/
sed -i 's|^|export |' /tmp/sample.conf
Expand Down Expand Up @@ -117,6 +119,12 @@ EOL
DEPLOYMENTS="$(find ./ -name '*deployment.yaml')"
mapfile -t DEPLOYMENTS <<< "$DEPLOYMENTS"
for variable in "${DEPLOYMENTS[@]}"; do
if grep -q livenessProbe "$variable"; then
sed -n "/.*livenessProbe/,/timeoutSeconds.*/p" "$variable" > /tmp/liveness.probe
cat /tmp/liveness.probe
sed -i "s|livenessProbe|readinessProbe|" /tmp/liveness.probe
sed -i "/^ image:/r /tmp/liveness.probe" "$variable"
fi
if grep -q volumeMounts "$variable"; then
if echo "$variable" | grep -q database; then
sed -i "/^ spec:/r /tmp/initcontainers.database" "$variable"
Expand Down Expand Up @@ -197,6 +205,8 @@ find ./ -name '*deployment.yaml' -exec sed -i "s|manual-install-nextcloud-aio|ne
# shellcheck disable=SC1083
find ./ -name '*deployment.yaml' -exec sed -i "/medium: Memory/d" \{} \;
# shellcheck disable=SC1083
find ./ -name '*.yaml' -exec sed -i "/kompose.cmd/d" \{} \;
# shellcheck disable=SC1083
find ./ -name '*deployment.yaml' -exec sed -i "s|emptyDir:|emptyDir: \{\}|" \{} \;
# shellcheck disable=SC1083
find ./ -name '*deployment.yaml' -exec sed -i "/hostPort:/d" \{} \;
Expand Down
30 changes: 30 additions & 0 deletions php/containers-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,36 @@
}
}
},
"healthcheck": {
"type": "object",
"additionalProperties": false,
"minProperties": 6,
"properties": {
"interval": {
"type": "string",
"pattern": "^[0-9]+s$"
},
"timeout": {
"type": "string",
"pattern": "^[0-9]+s$"
},
"retries": {
"type": "integer"
},
"start_period": {
"type": "string",
"pattern": "^[0-9]+s$"
},
"start_interval": {
"type": "string",
"pattern": "^[0-9]+s$"
},
"test": {
"type": "string",
"pattern": "^.*$"
}
}
},
"aio_variables": {
"type": "array",
"items": {
Expand Down
104 changes: 104 additions & 0 deletions php/containers.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@
"image": "nextcloud/aio-apache",
"user": "33",
"init": true,
"healthcheck": {
"start_period": "0s",
"test": "/healthcheck.sh",
"interval": "30s",
"timeout": "30s",
"start_interval": "5s",
"retries": 3
},
"ports": [
{
"ip_binding": "%APACHE_IP_BINDING%",
Expand Down Expand Up @@ -81,6 +89,14 @@
"image": "nextcloud/aio-postgresql",
"user": "999",
"init": true,
"healthcheck": {
"start_period": "0s",
"test": "/healthcheck.sh",
"interval": "30s",
"timeout": "30s",
"start_interval": "5s",
"retries": 3
},
"expose": [
"5432"
],
Expand Down Expand Up @@ -140,6 +156,14 @@
"display_name": "Nextcloud",
"image": "nextcloud/aio-nextcloud",
"init": true,
"healthcheck": {
"start_period": "0s",
"test": "/healthcheck.sh",
"interval": "30s",
"timeout": "30s",
"start_interval": "5s",
"retries": 3
},
"expose": [
"9000",
"9001"
Expand Down Expand Up @@ -255,6 +279,14 @@
"image": "nextcloud/aio-notify-push",
"user": "33",
"init": true,
"healthcheck": {
"start_period": "0s",
"test": "/healthcheck.sh",
"interval": "30s",
"timeout": "30s",
"start_interval": "5s",
"retries": 3
},
"expose": [
"7867"
],
Expand Down Expand Up @@ -297,6 +329,14 @@
"image": "nextcloud/aio-redis",
"user": "999",
"init": true,
"healthcheck": {
"start_period": "0s",
"test": "/healthcheck.sh",
"interval": "30s",
"timeout": "30s",
"start_interval": "5s",
"retries": 3
},
"expose": [
"6379"
],
Expand Down Expand Up @@ -333,6 +373,14 @@
"display_name": "Collabora",
"image": "nextcloud/aio-collabora",
"init": true,
"healthcheck": {
"start_period": "360s",
"test": "/healthcheck.sh",
"interval": "30s",
"timeout": "30s",
"start_interval": "5s",
"retries": 3
},
"expose": [
"9980"
],
Expand Down Expand Up @@ -372,6 +420,14 @@
"image": "nextcloud/aio-talk",
"user": "1000",
"init": true,
"healthcheck": {
"start_period": "0s",
"test": "/healthcheck.sh",
"interval": "30s",
"timeout": "30s",
"start_interval": "5s",
"retries": 3
},
"ports": [
{
"ip_binding": "",
Expand Down Expand Up @@ -429,6 +485,14 @@
"image": "nextcloud/aio-talk-recording",
"user": "122",
"init": true,
"healthcheck": {
"start_period": "0s",
"test": "/healthcheck.sh",
"interval": "30s",
"timeout": "30s",
"start_interval": "5s",
"retries": 3
},
"expose": [
"1234"
],
Expand Down Expand Up @@ -591,6 +655,14 @@
"image": "nextcloud/aio-clamav",
"user": "100",
"init": false,
"healthcheck": {
"start_period": "360s",
"test": "clamdcheck.sh",
"interval": "30s",
"timeout": "30s",
"start_interval": "5s",
"retries": 3
},
"expose": [
"3310"
],
Expand Down Expand Up @@ -630,6 +702,14 @@
"display_name": "OnlyOffice",
"image": "nextcloud/aio-onlyoffice",
"init": true,
"healthcheck": {
"start_period": "360s",
"test": "/healthcheck.sh",
"interval": "30s",
"timeout": "30s",
"start_interval": "5s",
"retries": 3
},
"expose": [
"80"
],
Expand Down Expand Up @@ -672,6 +752,14 @@
"image": "nextcloud/aio-imaginary",
"user": "65534",
"init": true,
"healthcheck": {
"start_period": "0s",
"test": "/healthcheck.sh",
"interval": "30s",
"timeout": "30s",
"start_interval": "5s",
"retries": 3
},
"expose": [
"9000"
],
Expand Down Expand Up @@ -708,6 +796,14 @@
"display_name": "Fulltextsearch",
"image": "nextcloud/aio-fulltextsearch",
"init": false,
"healthcheck": {
"start_period": "60s",
"test": "/healthcheck.sh",
"interval": "10s",
"timeout": "5s",
"start_interval": "5s",
"retries": 5
},
"expose": [
"9200"
],
Expand Down Expand Up @@ -778,6 +874,14 @@
"image": "nextcloud/aio-whiteboard",
"user": "65534",
"init": true,
"healthcheck": {
"start_period": "0s",
"test": "/healthcheck.sh",
"interval": "30s",
"timeout": "30s",
"start_interval": "5s",
"retries": 3
},
"expose": [
"3002"
],
Expand Down

0 comments on commit 9341392

Please sign in to comment.