Production Deployment
Deploying AnswerFlow for production is designed to be robust, scalable, and extremely flexible. We provide a complete, production-ready Docker Compose file (compose.prod.yaml) to get you running in minutes.
The “Batteries Included” Philosophy
Our default compose.prod.yaml is built on a “Batteries Included, But Removable” philosophy.
Out of the box, the Docker Compose file provisions the entire ecosystem:
web: The Next.js frontend and API.worker: The Node.js background processor (running BullMQ).db: A PostgreSQL database.redis: A Redis instance for caching and job queues.migrator: A temporary container that safely applies Prisma database migrations before the application accepts traffic.
Option 1: The Single-Server Setup (VPS)
If you are deploying to a single server (like a DigitalOcean Droplet, Hetzner, or AWS EC2), you can use the batteries-included setup exactly as it is.
Configure your environment
Ensure your .env is fully populated with production secrets (a strong AUTH_SECRET, real email provider API keys, and production S3 bucket configurations).
Start the cluster
Run the following command to build the images and start the cluster in detached mode:
docker compose -f compose.prod.yaml up --build -d3. Point Your Domain & Start the Cluster
AnswerFlow ships with Caddy built directly into the production cluster for automatic HTTPS/SSL.
CRITICAL: Before running the cluster, you must point your domain’s DNS A Record to your server’s IP address. If the DNS is not resolved, Caddy will fail to generate an SSL certificate.
Ensure your DOMAIN_NAME is set in your .env file:
DOMAIN_NAME=community.yourdomain.com
Then, build and start the cluster:
docker compose -f compose.prod.yaml up --build -dOption 2: The Enterprise Setup (Managed Services)
While running your own Database and Redis inside Docker is incredibly cost-effective, enterprise deployments at scale often require managed, highly available services like AWS RDS, Supabase, or Upstash.
You are actively encouraged to remove the local infrastructure “batteries” and plug in your own managed services.
How to remove the batteries:
- Open
compose.prod.yaml. - Delete the
dbandredisservice blocks entirely. - Remove the
depends_onarray references fordbandredisfrom theweb,worker, andmigratorservices. - Update your
.envfile to point to your managed infrastructure:
# Example: Using Supabase and Upstash
DATABASE_URL="postgresql://postgres:password@db.your-supabase.supabase.co:5432/postgres"
REDIS_URL="redis://default:password@your-upstash-url.upstash.io:6379"Because AnswerFlow strictly reads from your environment variables, the web and worker containers will seamlessly connect to your external managed services without any code changes!
Option 3: The Vercel / Serverless Route
If you prefer to deploy the Next.js frontend to an edge network like Vercel, you do not need to use Docker for the web application.
1. Vercel Configuration
Because AnswerFlow is a Turborepo monorepo, you must configure Vercel correctly so it knows which app to build.
- Import your GitHub repository into Vercel.
- CRITICAL: In the project settings, change the Root Directory to
apps/web. - Leave the Build Command and Install Command as their defaults (Vercel will automatically detect Turborepo and pnpm).
- Add all of your
.envvariables into the Vercel environment settings.
2. Handling the Background Worker
Serverless environments (like Vercel functions) spin up and down, meaning they cannot maintain a persistent connection to listen to a Redis queue. You have two options for your background worker:
Path A: Fully Serverless (Upstash QStash)
To stay 100% serverless, switch your queue adapter to QStash.
Add your QSTASH_URL, QSTASH_TOKEN, and signing keys to your Vercel environment variables. Vercel will act as the frontend, and QStash will trigger your Next.js webhook routes via HTTP to process background jobs.
Path B: The Hybrid Approach (Vercel + VPS Worker) You can host your Next.js frontend on Vercel for maximum edge performance, but run your background worker on a cheap $5 VPS (like DigitalOcean or Hetzner).
- Deploy
apps/webto Vercel. - On your VPS, use the
compose.prod.yamlfile but delete thewebandcaddyservices. - Spin up the Docker cluster. Your VPS will now act as a dedicated background processor (running Redis, the Worker, and optionally Postgres), while Vercel handles all user-facing web traffic!