fastapi icon indicating copy to clipboard operation
fastapi copied to clipboard

Add basic healthcheck operation to example Dockerfiles

Open nikstuckenbrock opened this issue 3 years ago • 7 comments

Fixes issue #5037.

nikstuckenbrock avatar Jun 15 '22 07:06 nikstuckenbrock

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Comparison is base (cf73051) 100.00% compared to head (ede312d) 100.00%. Report is 1038 commits behind head on master.

:exclamation: Current head ede312d differs from pull request most recent head 2c80d34. Consider uploading reports for the commit 2c80d34 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##            master     #5038    +/-   ##
==========================================
  Coverage   100.00%   100.00%            
==========================================
  Files          540       532     -8     
  Lines        13969     13684   -285     
==========================================
- Hits         13969     13684   -285     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar Jun 15 '22 07:06 codecov[bot]

📝 Docs preview for commit 52c1efffa5ee66683753a30115b5eb6c7191bcb2 at: https://62a9869ac63cd14f4579c012--fastapi.netlify.app

github-actions[bot] avatar Jun 15 '22 07:06 github-actions[bot]

Hey @iudeen,

thanks for the feedback.

Can you also add what the user has to add in the route? By default localhost/ would result in 404 NOTFOUND.

I've chosen the root route on purpose because every api needs one. I don't think it's a problem that the endpoint will result in a 404. The docker HEALTHCHECK command will only check the process result status of curl, which in case of a valid response, is 0, so the container is considered healthy.

Also, we should mention if bind port is changed, that port has to be given accordingly.

Yes, but the example is build using port 80. Maybe I should just include the port in the URL so it's more intuitive?

nikstuckenbrock avatar Jul 19 '22 06:07 nikstuckenbrock

Yes, but the example is build using port 80. Maybe I should just include the port in the URL so it's more intuitive?

Yes! and may be a comment or small note in the doc about it.

iudeen avatar Jul 19 '22 10:07 iudeen

Hey @iudeen,

I've provided a new version. Is that what you had in mind?

nikstuckenbrock avatar Jul 19 '22 17:07 nikstuckenbrock

📝 Docs preview for commit ede312d73f13b2f20a1a9ac4212c30a7e006d8d0 at: https://62d6ee7b7de9f41120bf9000--fastapi.netlify.app

github-actions[bot] avatar Jul 19 '22 17:07 github-actions[bot]

Hey @iudeen,

I've provided a new version. Is that what you had in mind?

Yes! This is good!!

iudeen avatar Jul 19 '22 18:07 iudeen

Thanks @nikstuckenbrock! 🤓

The consideration of what it means to be "healthy" would be quite dependent on the actual app, it could require a bunch of extra docs explaining all that... and there are also many other possible ideas or options that could be thought of as best practices, and it would not be feasible to include them all, or link to them all, also because it depends a lot on the specific team, etc.

So, for now, I'll pass on this one, but thanks for the effort! ☕

tiangolo avatar Jan 16 '24 14:01 tiangolo