This guide provides instructions for deploying the QCX stack (Next.js, PostgreSQL with pgvector/PostGIS, and Qdrant) to various cloud platforms.
The application consists of:
- QCX Web App: Next.js application running on Bun.
- PostgreSQL: Database with
pgvectorandPostGISextensions. - Qdrant: High-performance vector database (optional, for advanced vector search).
The easiest way to deploy the entire stack is using docker-compose.
- Clone the repository on your server.
- Create a
.envfile based on the environment variables indocker-compose.yaml. - Run the stack:
docker-compose up -d --build
Render is a great choice for managed services.
- Create a New PostgreSQL instance on Render.
- Note: Standard Render Postgres does not include
pgvectororPostGISby default on all plans. You may need to use a Docker-based Postgres on Render or ensure your plan supports these extensions. - If using Render's managed Postgres, run the extensions command manually via a SQL client:
CREATE EXTENSION IF NOT EXISTS postgis; CREATE EXTENSION IF NOT EXISTS vector;
- Create a New Web Service pointing to your repository.
- Select Docker as the runtime.
- Specify the Dockerfile path as
Dockerfile. - Add environment variables:
DATABASE_URL: Your Render Postgres connection string.EXECUTE_MIGRATIONS:trueNEXT_PUBLIC_MAPBOX_ACCESS_TOKEN: Your Mapbox token.- (Add other necessary API keys like Google, xAI, etc.)
- Create a New Private Service or Web Service.
- Select Docker as the runtime.
- Use the image:
qdrant/qdrant:latest. - Set
QDRANT_URLin your Web Service to point to this service.
- Build and Push the image to Google Artifact Registry:
docker build -t gcr.io/YOUR_PROJECT/qcx . docker push gcr.io/YOUR_PROJECT/qcx - Deploy to Cloud Run:
gcloud run deploy qcx --image gcr.io/YOUR_PROJECT/qcx --platform managed
- Create a Cloud SQL for PostgreSQL instance (version 15+).
- Cloud SQL supports both
pgvectorandpostgis. Enable them via:CREATE EXTENSION IF NOT EXISTS postgis; CREATE EXTENSION IF NOT EXISTS vector;
QCX is configured to support two vector database options:
- PostgreSQL (pgvector): Integrated into the main database. Best for smaller datasets and simplicity.
- Qdrant: Dedicated vector database. Recommended for large-scale production use cases requiring high performance and advanced filtering.
To use Qdrant, ensure the QDRANT_URL environment variable is set in your application environment.
- Change default passwords in
docker-compose.yaml. - Use SSL for database connections in production (
ssl=trueinDATABASE_URL). - Set
NODE_ENV=production. - Ensure all sensitive API keys are stored as secrets, not committed to code.