-
Notifications
You must be signed in to change notification settings - Fork 18
feat(routes): add health check endpoint #364
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughA health check endpoint was added to the FastAPI application. The Dockerfile was updated to include a health check using a new shell script, additional metadata labels, and reorganized file copying. New tests verify the Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant FastAPI App
participant HealthRoute
Client->>FastAPI App: GET /health
FastAPI App->>HealthRoute: Call health_check()
HealthRoute-->>FastAPI App: {"status": "ok"}
FastAPI App-->>Client: 200 OK, {"status": "ok"}
Possibly related PRs
Note ⚡️ AI Code Reviews for VS Code, Cursor, WindsurfCodeRabbit now has a plugin for VS Code, Cursor and Windsurf. This brings AI code reviews directly in the code editor. Each commit is reviewed immediately, finding bugs before the PR is raised. Seamless context handoff to your AI code agent ensures that you can easily incorporate review feedback. Note ⚡️ Faster reviews with cachingCodeRabbit now supports caching for code and dependencies, helping speed up reviews. This means quicker feedback, reduced wait times, and a smoother review experience overall. Cached data is encrypted and stored securely. This feature will be automatically enabled for all accounts on May 16th. To opt out, configure ✨ Finishing Touches
🧪 Generate Unit Tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
|
Coverage summary from CodacySee diff coverage on Codacy
Coverage variation details
Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: Diff coverage details
Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: See your quality gate settings Change summary preferences |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #364 +/- ##
==========================================
+ Coverage 89.18% 89.65% +0.46%
==========================================
Files 2 3 +1
Lines 111 116 +5
==========================================
+ Hits 99 104 +5
Misses 12 12
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
Dockerfile(2 hunks)main.py(2 hunks)routes/health_route.py(1 hunks)scripts/healthcheck.sh(1 hunks)tests/test_main.py(1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
tests/test_main.py (1)
tests/conftest.py (1)
client(11-13)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: Codacy Static Code Analysis
🔇 Additional comments (15)
main.py (1)
9-9: Clean implementation of health route integration!The health route has been properly imported and included in the FastAPI application's routers. This follows the standard pattern for extending the API with new functionality.
Also applies to: 29-29
tests/test_main.py (1)
10-22: Well-structured test for the health endpoint!The test properly verifies both the status code (200) and response body (
{"status": "ok"}), following the existing test pattern in the project. Good job adding test coverage for the new endpoint.scripts/healthcheck.sh (1)
1-5: Robust and concise health check script!The script follows shell best practices by using
set -eto fail fast andcurl --failto properly handle HTTP error codes. This provides a reliable mechanism for container health verification.routes/health_route.py (1)
1-15: Well-implemented health check endpoint!The health route is cleanly implemented following FastAPI best practices, with proper router setup, endpoint definition, and documentation. The simple JSON response is appropriate for a health check endpoint.
Dockerfile (11)
14-17: Pre-built wheels for reproducible builds
Building all dependencies into wheels ensures faster, more reliable installs downstream. The use of--no-cache-dirand a dedicated wheelhouse is spot on.
23-23: Consistent base image for runtime stage
Reusingpython:3.13.3-slim-bookwormin the runtime stage guarantees compatibility with the builder artifacts.
26-29: Installingcurlfor health checks
Good use of a minimal install and immediate cleanup of apt caches to keep the image lean.
30-35: Adding OCI metadata labels
Including descriptive labels (title,description,licenses,source) improves discoverability in container registries. Nice addition.
36-39: Copying documentation early to leverage caching
MovingREADME.mdandassetsbefore dependency install enables better layer caching when docs change less frequently than code.
40-42: Copying wheelhouse from builder stage
Ensures an offline, deterministic installation. This helps in air-gapped environments.
43-47: Installing dependencies from local wheelhouse
The use of--no-indexwith a local wheel cache plus clean-up of the wheelhouse is a best practice for minimal images.
48-55: Simplified source code copy
Dropping explicit--chownflags is fine since default permissions (0644) allow read access for non-root. This keeps the Dockerfile concise.
61-66: Non-root user and mount-point setup
Creating afastapisystem user and configuring/storagewith proper ownership is the right approach for security and writable volumes.
67-68: Unbuffered Python output
SettingPYTHONUNBUFFERED=1early ensures logs are flushed unbuffered—essential for real-time container logging.
74-76: Healthcheck directive using custom script
TheHEALTHCHECKexec form with retries and timeouts pointing tohealthcheck.shis correctly configured for container orchestration.



This change is
Summary by CodeRabbit
/healthendpoint to provide a simple health check for the service./healthendpoint responds with status 200 and expected output.