Deploy FastAPI on Your Own Server

Deploy FastAPI applications with Uvicorn ASGI server and managed PostgreSQL. Your OpenAPI docs and Swagger UI work out of the box.


Quickstart

From your project root, deploy with your preferred package manager:

npx @temps-sdk/cli up

Temps detects your requirements.txt, installs dependencies, and starts your app with Uvicorn. Your /docs (Swagger UI) and /redoc endpoints are accessible immediately.


What Temps Handles Automatically

FeatureHow Temps handles it
Installpip install -r requirements.txt
ASGI serverUvicorn with multiple workers
OpenAPI/docs and /redoc served automatically
MigrationsRun alembic upgrade head via deploy hook
HTTPSLet's Encrypt certificate, auto-renewed
PortPORT env var injected, defaults to 8000
WebSocketsFully supported via Uvicorn

Procfile

Define your start command in a Procfile at the project root:

web: uvicorn main:app --host 0.0.0.0 --port $PORT --workers 4

Alembic Migrations

To run migrations on every deploy, add a deploy hook in Project → Settings → Deploy Hooks:

alembic upgrade head

Environment Variables

npx @temps-sdk/cli environments vars set DATABASE_URL "postgresql+asyncpg://user:pass@host/db" -e production

npx @temps-sdk/cli environments vars set SECRET_KEY "your-secret-key" -e production

Managed PostgreSQL and Redis

Add services from Project → Services → Add Service. Temps injects connection strings as environment variables automatically.


Platform behavior

These rules apply to every app deployed on Temps, regardless of framework.

Health checks

After your container starts, Temps sends HTTP GET requests to verify it is healthy before routing traffic to it.

  • Path: / (the root of your application)
  • Success: 2 consecutive responses with a 2xx or 3xx status code
  • Timeout: 300 seconds (5 minutes) for the app to become healthy
  • Retry interval: every 5 seconds

Connection errors while the app is still starting are retried without penalty. If the app returns 4xx or 5xx errors for 60 consecutive seconds, the deployment fails. Customize the check by adding a .temps.yaml to your repository root:

.temps.yaml
health:
  path: /health
  status: 200
  interval: 30
  timeout: 5
  retries: 3

Auto-injected environment variables

Temps injects these variables into every deployment automatically:

VariableValueDescription
PORTResolved portThe port your app must listen on
HOST0.0.0.0Bind address
SENTRY_DSNAuto-generatedError tracking endpoint
TEMPS_API_URLYour Temps URLPlatform API endpoint
TEMPS_API_TOKENDeployment tokenAuthentication for Temps SDKs
OTEL_EXPORTER_OTLP_ENDPOINTYour Temps OTLP URLOpenTelemetry trace collection
OTEL_SERVICE_NAMEProject nameService identifier for traces

You do not need to configure these manually. They are available in process.env (Node.js), os.environ (Python), os.Getenv (Go), and the equivalent in other languages.


Next Steps

Was this page helpful?