Fly.io Deployment¶
Deploy the Pisama backend to Fly.io for low-latency, globally distributed hosting.
Backend Deployment¶
Deploy from the repo root. The fly.toml and Dockerfile live there, with the Docker build context set to the repo root (there is no separate backend/Dockerfile).
# Create the app
fly launch --name pisama-api --no-deploy
# Set secrets
fly secrets set \
JWT_SECRET=$(openssl rand -base64 32) \
DATABASE_URL="postgresql+asyncpg://user:pass@host:5432/pisama" \
REDIS_URL="redis://host:6379" \
ENVIRONMENT=production \
CORS_ORIGINS="https://your-frontend.vercel.app"
# Deploy
fly deploy
Dockerfile¶
The Dockerfile at the repo root is production-ready:
- Python 3.11-slim base image
- Non-root user (
pisama) for security - CPU-only PyTorch for sentence-transformers (smaller image)
- Built-in health check on
/health - Configurable port via
$PORTenvironment variable
Scaling¶
# Scale to 2 instances
fly scale count 2
# Increase memory (embedding models need ~1GB)
fly scale memory 1024
# View current scaling
fly scale show
Database Options¶
Fly.io does not provide managed PostgreSQL with pgvector. Options:
| Provider | Recommended For | pgvector |
|---|---|---|
| Supabase | Hobby / Startup | Pre-installed |
| Neon | Serverless workloads | Available |
| AWS RDS | Enterprise | Manual enable |
| Fly Postgres | Simple setup | Manual enable |
Ensure you enable the pgvector extension:
Frontend Deployment¶
Deploy the frontend to Vercel (recommended) or as a separate Fly.io app:
Health Check¶
curl https://api.pisama.ai/api/v1/health
# {"status": "healthy", "database": "healthy", "redis": "healthy", "version": "..."}
Monitoring¶
Fly.io provides built-in logging and metrics:
Pisama also exposes Prometheus metrics: