feat: add health check and heartbeat endpoint to Docker setup
All checks were successful
Build and Push Docker Image / build (push) Successful in 1m26s

This commit is contained in:
2025-02-15 14:12:34 +01:00
parent 0518d1ba48
commit 5636d92474
2 changed files with 15 additions and 4 deletions

View File

@@ -4,6 +4,9 @@ FROM python:3.13.1-slim-bookworm
COPY requirements.txt /app/requirements.txt
RUN pip install --no-cache-dir -r /app/requirements.txt
# Install curl
RUN apt-get update && apt-get install -y curl
# Copy the application
COPY main.py /app
COPY utils/ /app/utils
@@ -11,3 +14,6 @@ WORKDIR /app
# Run the application
CMD ["python", "main.py"]
# Healthcheck
HEALTHCHECK --interval=5s --timeout=10s --retries=5 CMD curl -f http://localhost/heartbeat || exit 1

View File

@@ -24,6 +24,11 @@ class Handler(BaseHTTPRequestHandler):
self.wfile.write(b'404 Not Found')
def do_GET(self):
self.send_response(404)
self.end_headers()
self.wfile.write(b'404 Not Found')
if self.path == '/heartbeat':
self.send_response(200)
self.end_headers()
self.wfile.write(b'Heartbeat OK')
else:
self.send_response(404)
self.end_headers()
self.wfile.write(b'404 Not Found')