APIs & backends

    Deploy FastAPI on Oracle Cloud's free tier

    Uvicorn workers behind Caddy on an ARM VM — async APIs, WebSockets and background tasks that never sleep.

    At a glance

    Base imagepython:3.12-slim
    Port8000
    Build commandpip install -r requirements.txt
    Start commanduvicorn app.main:app --host 0.0.0.0 --port 8000
    Infrastructure cost$0 on Oracle Always Free (platform fee for managed DevOps)

    Running FastAPI on Ampere ARM

    uvloop and httptools both ship aarch64 wheels, so the standard extras install cleanly on Ampere. Long-lived WebSocket connections are the big win over serverless: nothing terminates the process between requests.

    Steps

    1. Expose a health endpoint. Cheaploy's blue/green deploy waits for this before shifting traffic.
      @app.get("/healthz")
      def healthz():
          return {"status": "ok"}
    2. Add the Dockerfile. Two Uvicorn workers per OCPU is a good starting point for an async workload.
    3. Deploy and watch the logs. Streamed logs and CPU/memory graphs are in the project dashboard.

    Dockerfile for FastAPI on ARM64

    FROM python:3.12-slim
    WORKDIR /app
    ENV PYTHONUNBUFFERED=1
    COPY requirements.txt .
    RUN pip install --no-cache-dir -r requirements.txt "uvicorn[standard]"
    COPY . .
    EXPOSE 8000
    CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000", "--workers", "2"]

    Need one tailored to your repository? The free Dockerfile generator writes an ARM-ready multi-stage build for you.

    Common mistakes

    • Blocking calls in async routes: A synchronous database driver inside an `async def` blocks the whole event loop. Use `def` routes or an async driver.
    • No reverse proxy headers: Run with `--proxy-headers` so request.url and redirects use https, not http.
    • Workers x memory: Each Uvicorn worker is a full process. Four workers of a 400 MB model will exhaust a 6 GB instance faster than you expect.

    Related reading

    Get the Oracle Always Free deploy checklist

    One email with the exact steps, capacity workarounds and tools we use to ship apps for $0 of cloud spend.

    One email, no spam. Unsubscribe anytime.

    Frequently asked

    Do WebSockets work?+

    Yes. The container is a persistent process behind Caddy, so WebSocket and SSE connections stay open as long as the client keeps them.

    Can I run background jobs?+

    Yes — FastAPI background tasks, APScheduler or a separate worker container all work because the VM is always on.

    What about GPU inference?+

    Oracle's Always Free tier has no GPU. CPU inference on small models works on the 4 OCPU ARM shape.

    Deploy your project for $0

    No credit card. No Oracle sales call. Ship to your own cloud in under 10 minutes.

    Start free