Menu

How to deploy a FastAPI app on Ownkube
📰

How to deploy a FastAPI app on Ownkube

DEV Community: fastapi·Abhishek Jaiswal·14 days ago
#AbbNcv2L
#devtofastapi#devto#dev#ownkube#fastapi
Reading 0:00
15s threshold

FastAPI is fast to run locally with uvicorn app.main:app --reload , and the production version of that command is not much longer. Production adds three things: a process manager that restarts a crashed worker, config read from environment variables instead of a .env file in the repo, and a health check for the platform to poll. Ownkube handles the rest from a git push.

This walks through deploying a FastAPI app on Ownkube Compute: running Gunicorn with Uvicorn workers, configuring settings through environment variables , adding a health check endpoint, and turning on autoscaling .

TL;DR

Push a FastAPI app with a Dockerfile , and Ownkube builds it, deploys it, and issues TLS automatically on your *.ownkube.app hostname.

Run Gunicorn with uvicorn.workers.UvicornWorker in production rather than Uvicorn's dev server directly, so a crashed worker restarts instead of taking the app down.

Load configuration through a Pydantic BaseSettings class and set the real values as environment variables in the…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.