Deploying to Fly.io
Fly.io runs your app in persistent containers across global regions. It is a strong choice for production SSE workloads.
Dockerfile
FROM python:3.12-slim
WORKDIR /app
COPY requirements.txt .
RUN pip install -r requirements.txt
COPY . .
EXPOSE 8080
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8080"]
fly.toml (key sections)
[http_service]
internal_port = 8080
force_https = true
auto_stop_machines = false
auto_start_machines = true
Deploy
SSE Note
Set auto_stop_machines = false for SSE. Stopped machines will drop active streaming connections.
If you front Fly.io with Nginx, use this SSE proxy block: