From 78a97db3209721ab1173c9be391cdfe6593b7946 Mon Sep 17 00:00:00 2001 From: Marc Partensky Date: Fri, 25 Feb 2022 01:46:00 +0100 Subject: [PATCH] healthcheck --- Dockerfile | 1 + __main__.py | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/Dockerfile b/Dockerfile index be4d48d..894549f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,4 +5,5 @@ RUN pip install -r requirements.txt EXPOSE 8000 +HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 CMD [ "curl", "-sSf", "localhost:8000" ] ENTRYPOINT ["python", "__main__.py"] diff --git a/__main__.py b/__main__.py index 00882ec..08bddfa 100755 --- a/__main__.py +++ b/__main__.py @@ -20,8 +20,13 @@ RABBIT_PORT = os.environ.get("RABBIT_PORT") or "5672" app = FastAPI() def get_connexion(): + """Return the RabbitMQ connexion object.""" return pika.BlockingConnection(pika.ConnectionParameters(RABBIT_HOST+":"+RABBIT_PORT)) +@app.get("/live") +def healthcheck(): + """Health check for Docker.""" + return "OK" @app.get("/{repo}") def webhook(repo: str):