DEV Community

SnapDeploy
SnapDeploy

Posted on • Originally published at snapdeploy.dev

How to Deploy a FastAPI App Fast

TL;DR: Deploy a FastAPI app in under 60 seconds — connect GitHub, port 8000 is auto-detected, click deploy. No Dockerfile needed. Database add-on available with auto-injected env vars.


FastAPI has become the go-to framework for building Python APIs. It's fast, modern, and developer-friendly.

But deployment? That's where the friction usually starts.

This guide shows you how to go from GitHub repo to live API in under a minute.


Prerequisites

  • A FastAPI application on GitHub
  • A free-tier container hosting account

The FastAPI Application

# main.py
from fastapi import FastAPI

app = FastAPI(title="My API")

@app.get("/")
def read_root():
    return {"status": "healthy"}

@app.get("/items/{item_id}")
def read_item(item_id: int):
    return {"item_id": item_id}
Enter fullscreen mode Exit fullscreen mode

Nothing fancy. Standard FastAPI starter.


Deploy in 60 Seconds

Seconds 0-15: Connect GitHub

Log in, click "New Container", select your repository.

Seconds 15-30: Configure

Name your container. Port 8000 is auto-detected for FastAPI.

Seconds 30-45: Environment Variables

Add any secrets: DATABASE_URL, API_KEY, etc.

Seconds 45-60: Deploy

Click "Deploy". The platform automatically:

  • Detects Python from requirements.txt
  • Identifies FastAPI framework
  • Installs dependencies
  • Starts uvicorn

No Dockerfile needed. No build configuration.


Smart Detection

The platform scans your codebase for:

File/Pattern What It Detects
requirements.txt Python project
from fastapi import FastAPI FastAPI framework
app = FastAPI() App entry point

Everything is inferred automatically.


Adding a Database

Need PostgreSQL? Three clicks:

  1. Go to "Add-ons" in your dashboard
  2. Click "Create Add-On" and select PostgreSQL
  3. Link to your container

Environment variables are automatically injected:

DATABASE_URL=postgresql://user:pass@host:5432/mydb
POSTGRES_HOST=internal-host
POSTGRES_PORT=5432
Enter fullscreen mode Exit fullscreen mode

No manual connection strings. No .env file juggling. It just works.


Automatic API Docs

FastAPI's built-in docs work immediately after deployment:

Docs URL
Swagger UI https://your-app.snapdeploy.app/docs
ReDoc https://your-app.snapdeploy.app/redoc

Both accessible instantly. No extra setup.


Key Takeaways

  • FastAPI deploys in under 60 seconds with auto-detection
  • Port 8000 is auto-configured — no manual port mapping
  • Database add-ons inject env vars automatically — no connection string juggling
  • Swagger + ReDoc work out of the box after deployment

If you're building APIs with FastAPI, deployment shouldn't be the hard part.

Top comments (0)