From 783c4533e42f0c61e4bef1d86ba46ad228b26707 Mon Sep 17 00:00:00 2001 From: Erwan Rouchet <rouchet@teklia.com> Date: Thu, 17 Aug 2023 15:10:02 +0200 Subject: [PATCH] Add Docker healthcheck --- Dockerfile | 6 +++++- Dockerfile.binary | 4 ++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index d9ec2f56de..28317a3598 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,3 +1,4 @@ +# syntax=docker/dockerfile:1 FROM registry.gitlab.teklia.com/arkindex/backend/base:gitlab-teklia as build RUN mkdir build @@ -41,7 +42,10 @@ RUN chown -R ark:teklia /backend_static # Copy Version file COPY VERSION /etc/arkindex.version -# Run with Daphne +HEALTHCHECK --start-period=1m --start-interval=1s --interval=1m --timeout=5s \ + CMD wget --spider --quiet http://localhost/api/v1/public-key/ || exit 1 + +# Run with Gunicorn ENV PORT 80 EXPOSE 80 CMD ["manage.py", "gunicorn", "--host=0.0.0.0"] diff --git a/Dockerfile.binary b/Dockerfile.binary index 78e741af1f..a4e90ae72e 100644 --- a/Dockerfile.binary +++ b/Dockerfile.binary @@ -1,3 +1,4 @@ +# syntax=docker/dockerfile:1 FROM python:3.10-slim-bookworm AS compilation RUN apt-get update && apt-get install --no-install-recommends -y build-essential wget @@ -87,6 +88,9 @@ COPY arkindex/documents/export/*.sql /usr/share/arkindex/documents/export/ # Otherwise Django will not load the compiled module RUN for cmd in $(cat /usr/share/arkindex/commands.txt); do mkdir -p $(dirname $cmd); touch $cmd; done +HEALTHCHECK --start-period=1m --start-interval=1s --interval=1m --timeout=5s \ + CMD wget --spider --quiet http://localhost/api/v1/public-key/ || exit 1 + # Run gunicorn server ENV PORT=80 EXPOSE 80 -- GitLab