From 0e129e9f6af95bc656a4e191ddb2e2b7358c9966 Mon Sep 17 00:00:00 2001 From: Gabriele Tramonte Date: Tue, 30 Jul 2024 11:16:44 +0200 Subject: [PATCH] Adding healtchecks for API pods via cron --- api/Dockerfile | 10 ++++++++++ api/healtcheck.cron | 1 + api/healtcheck.sh | 1 + 3 files changed, 12 insertions(+) create mode 100644 api/healtcheck.cron create mode 100644 api/healtcheck.sh diff --git a/api/Dockerfile b/api/Dockerfile index c038cb3..310e7cc 100644 --- a/api/Dockerfile +++ b/api/Dockerfile @@ -1,9 +1,19 @@ ARG REGISTRY=rg.fr-par.scw.cloud/geolake ARG TAG=latest FROM $REGISTRY/geolake-datastore:$TAG + +RUN apt update && apt install -y cron + WORKDIR /app COPY requirements.txt /code/requirements.txt RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt COPY app /app EXPOSE 80 + +COPY ./healtcheck.* /opt/ + +RUN chmod +x /opt/healtcheck.sh +RUN crontab -u root /opt/healtcheck.cron +RUN service cron start + CMD ["uvicorn", "app.main:app", "--proxy-headers", "--host", "0.0.0.0", "--port", "80"] diff --git a/api/healtcheck.cron b/api/healtcheck.cron new file mode 100644 index 0000000..e11f6da --- /dev/null +++ b/api/healtcheck.cron @@ -0,0 +1 @@ +*/10 * * * * bash -c '/opt/healtcheck.sh' \ No newline at end of file diff --git a/api/healtcheck.sh b/api/healtcheck.sh new file mode 100644 index 0000000..4d8e479 --- /dev/null +++ b/api/healtcheck.sh @@ -0,0 +1 @@ +curl https://hc-ping.com/$HEALTCHECKS \ No newline at end of file