Skip to content

Commit

Permalink
Add a simple docker curl healthcheck
Browse files Browse the repository at this point in the history
  • Loading branch information
fidoriel committed Feb 7, 2025
1 parent 7e1bcc4 commit 6d76556
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ FROM python:3.12-slim
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1

RUN apt-get update -y && apt-get install curl -y

WORKDIR /code

COPY --from=node-builder /code/dist/ /code/dist/
Expand All @@ -38,4 +40,7 @@ ENV PATH="$VIRTUAL_ENV/bin:$PATH"

EXPOSE 8080

HEALTHCHECK --interval=10s --timeout=5s --start-period=3s --retries=3 \
CMD curl --fail http://localhost:8080/healthz || exit 1

CMD ["uvicorn", "backend.main:app", "--host", "0.0.0.0", "--port", "8080"]
6 changes: 6 additions & 0 deletions backend/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@
allow_headers=["*"],
)


@app.get("/healthz")
async def healthz() -> dict[str, str]:
return {"status": "healthy"}


app.include_router(api_router, prefix="/api")
app.include_router(ws_router, prefix="/ws")

Expand Down

0 comments on commit 6d76556

Please sign in to comment.