From 0e05c77fa76395453a5877b2250600a0773c247b Mon Sep 17 00:00:00 2001 From: zodac Date: Fri, 29 Nov 2024 14:15:24 +1300 Subject: [PATCH 1/2] Adding healthcheck to docker image --- Dockerfile | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Dockerfile b/Dockerfile index 4b52f246da..08edfa5a46 100644 --- a/Dockerfile +++ b/Dockerfile @@ -35,6 +35,12 @@ RUN apk add --no-cache --virtual .build-deps gcc musl-dev postgresql-dev zlib-de #Copy project and execute it. COPY . ./ +HEALTHCHECK --interval=30s \ + --timeout=5s \ + --start-period=10s \ + --retries=3 \ + CMD [ "/usr/bin/wget", "--no-verbose", "--tries=1", "-O", "-", "http://127.0.0.1:8080/openapi" ] + # collect information from git repositories RUN /opt/recipes/venv/bin/python version.py # delete git repositories to reduce image size From 103daf000d4b6b793d30b6571ddc46997e26ba4f Mon Sep 17 00:00:00 2001 From: zodac Date: Mon, 2 Dec 2024 20:44:12 +1300 Subject: [PATCH 2/2] Using --spider for healthcheck, which performs a HEAD request instead of a GET request --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 08edfa5a46..d2b92c1a5e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -39,7 +39,7 @@ HEALTHCHECK --interval=30s \ --timeout=5s \ --start-period=10s \ --retries=3 \ - CMD [ "/usr/bin/wget", "--no-verbose", "--tries=1", "-O", "-", "http://127.0.0.1:8080/openapi" ] + CMD [ "/usr/bin/wget", "--no-verbose", "--tries=1", "--spider", "http://127.0.0.1:8080/openapi" ] # collect information from git repositories RUN /opt/recipes/venv/bin/python version.py