Add healthcheck

This commit is contained in:
2023-05-17 17:06:38 +02:00
parent 281f1425de
commit 403849c483
2 changed files with 11 additions and 6 deletions

View File

@@ -1,4 +1,4 @@
FROM ghcr.io/flibusta-apps/base_docker_images:3.11-postgres-asyncpg-poetry-buildtime as build-image FROM ghcr.io/flibusta-apps/base_docker_images:3.11-postgres-asyncpg-poetry-buildtime AS build-image
WORKDIR /root/poetry WORKDIR /root/poetry
COPY pyproject.toml poetry.lock /root/poetry/ COPY pyproject.toml poetry.lock /root/poetry/
@@ -10,7 +10,7 @@ RUN poetry export --without-hashes > requirements.txt \
&& pip install -r requirements.txt --no-cache-dir && pip install -r requirements.txt --no-cache-dir
FROM ghcr.io/flibusta-apps/base_docker_images:3.11-postgres-runtime as runtime-image FROM ghcr.io/flibusta-apps/base_docker_images:3.11-postgres-runtime AS runtime-image
WORKDIR /app WORKDIR /app
@@ -24,4 +24,6 @@ COPY --from=build-image $VENV_PATH $VENV_PATH
EXPOSE 8080 EXPOSE 8080
HEALTHCHECK CMD python3 /root/healthcheck.py
CMD bash /root/start.sh CMD bash /root/start.sh

View File

@@ -1,8 +1,11 @@
import os
import httpx import httpx
response = httpx.get( CHECK_URL = os.environ.get("HEALTHCHECK_URL", "http://localhost:8080/healthcheck")
"http://localhost:8080/healthcheck",
) response = httpx.get(CHECK_URL)
print(f"HEALTHCHECK STATUS: {response.status_code}")
print(f"HEALTHCHECK STATUS: {response.text}")
exit(0 if response.status_code == 200 else 1) exit(0 if response.status_code == 200 else 1)