Documentation menu

Deploy FastAPI on Light Cloud - a Python container on port 8000, served by Uvicorn bound to the routed port.

Deploy FastAPI

FastAPI is detected from your dependencies and runs as a Python container on port 8000. No Dockerfile needed - one is generated unless the repo has its own.

Serve it#

Bind 0.0.0.0 on the routed port - PORT is set to it:

uvicorn app.main:app --host 0.0.0.0 --port $PORT

Configuration and database#

Read environment variables at startup - os.environ, or pydantic-settings, which maps them to a settings model. For the database, set DATABASE_URL from the Credentials tab - SQLAlchemy and the async drivers take the URL directly; keep sslmode=require in place.

Run Alembic migrations at startup or from your laptop against the same endpoint - see Connect from your laptop.

Scaling#

Async I/O suits the default concurrency of 80. CPU-bound endpoints (ML inference, heavy serialization) want it lower - 10-20 - or a bigger size. Scale to zero covers idle time; connect to the database lazily so cold starts stay short.