-
-
Notifications
You must be signed in to change notification settings - Fork 8
Vercel Sandbox Integration #640
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
58859ab
d41ece3
ecbd4c3
8fc5dda
dccf04b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -80,7 +80,6 @@ docker-compose*.yml | |
| cloudbuild.yaml | ||
|
|
||
| # Drizzle | ||
| drizzle/ | ||
|
|
||
| # Scripts | ||
| install.sh | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -29,3 +29,12 @@ NEXT_PUBLIC_SUPABASE_URL=YOUR_SUPABASE_URL_HERE | |||||||||||||||||||||||
| NEXT_PUBLIC_SUPABASE_ANON_KEY=YOUR_SUPABASE_ANON_KEY_HERE | ||||||||||||||||||||||||
| SUPABASE_SERVICE_ROLE_KEY=YOUR_SUPABASE_SERVICE_ROLE_KEY_HERE | ||||||||||||||||||||||||
| DATABASE_URL=postgresql://postgres:[YOUR-POSTGRES-PASSWORD]@[YOUR-SUPABASE-DB-HOST]:[PORT]/postgres | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| # Vercel Sandbox (MicroVM Infrastructure) | ||||||||||||||||||||||||
| # Required for OIDC-based microVM authentication | ||||||||||||||||||||||||
| # VERCEL_TOKEN: Create a Personal Access Token in Vercel Dashboard > Settings > Tokens | ||||||||||||||||||||||||
| VERCEL_TOKEN=your_vercel_token | ||||||||||||||||||||||||
| # VERCEL_TEAM_ID: Found in Vercel Dashboard > Team Settings > General (starts with 'team_') | ||||||||||||||||||||||||
| VERCEL_TEAM_ID=your_vercel_team_id | ||||||||||||||||||||||||
| # VERCEL_PROJECT_ID: Found in Vercel Dashboard > [Project] > Settings > General (starts with 'prj_') | ||||||||||||||||||||||||
|
Comment on lines
+35
to
+39
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing Line 39 shows the comment for ✅ Proposed fix to complete the configuration # VERCEL_PROJECT_ID: Found in Vercel Dashboard > [Project] > Settings > General (starts with 'prj_')
+VERCEL_PROJECT_ID=your_vercel_project_id📝 Committable suggestion
Suggested change
🧰 Tools🪛 dotenv-linter (4.0.0)[warning] 38-38: [UnorderedKey] The VERCEL_TEAM_ID key should go before the VERCEL_TOKEN key (UnorderedKey) 🤖 Prompt for AI Agents |
||||||||||||||||||||||||
| VERCEL_PROJECT_ID=your_vercel_project_id | ||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,97 @@ | ||
| # Cloud Deployment Guide for QCX | ||
|
|
||
| This guide provides instructions for deploying the QCX stack (Next.js, PostgreSQL with pgvector/PostGIS, and Qdrant) to various cloud platforms. | ||
|
|
||
| ## Infrastructure Overview | ||
|
|
||
| The application consists of: | ||
| 1. **QCX Web App**: Next.js application running on Bun. | ||
| 2. **PostgreSQL**: Database with `pgvector` and `PostGIS` extensions. | ||
| 3. **Qdrant**: High-performance vector database (optional, for advanced vector search). | ||
|
|
||
| --- | ||
|
|
||
| ## 1. Deploying with Docker Compose (VPS / EC2 / Compute Engine) | ||
|
|
||
| The easiest way to deploy the entire stack is using `docker-compose`. | ||
|
|
||
| 1. **Clone the repository** on your server. | ||
| 2. **Create a `.env` file** based on the environment variables in `docker-compose.yaml`. | ||
| 3. **Run the stack**: | ||
| ```bash | ||
| docker-compose up -d --build | ||
| ``` | ||
|
Comment on lines
+14
to
+23
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add production persistence guidance for docker-compose. The Docker Compose section omits important production considerations. Add notes on volume persistence and backup strategy: 💾 Suggested additionsAdd after line 22: 4. **Verify persistence** (important for production):
- Ensure `postgres_data` and `qdrant_data` volumes are properly mounted on the host.
- Implement regular backups of these volumes.
- Consider external managed databases (RDS, Cloud SQL, Neon) for production workloads.🧰 Tools🪛 markdownlint-cli2 (0.22.1)[warning] 21-21: Fenced code blocks should be surrounded by blank lines (MD031, blanks-around-fences) 🤖 Prompt for AI Agents |
||
|
|
||
| --- | ||
|
|
||
| ## 2. Deploying to Render | ||
|
|
||
| Render is a great choice for managed services. | ||
|
|
||
| ### PostgreSQL (Managed) | ||
| 1. Create a **New PostgreSQL** instance on Render. | ||
| 2. **Note**: Standard Render Postgres does not include `pgvector` or `PostGIS` by default on all plans. You may need to use a Docker-based Postgres on Render or ensure your plan supports these extensions. | ||
| 3. If using Render's managed Postgres, run the extensions command manually via a SQL client: | ||
| ```sql | ||
| CREATE EXTENSION IF NOT EXISTS postgis; | ||
| CREATE EXTENSION IF NOT EXISTS vector; | ||
| ``` | ||
|
|
||
| ### Web Service | ||
| 1. Create a **New Web Service** pointing to your repository. | ||
| 2. Select **Docker** as the runtime. | ||
| 3. Specify the **Dockerfile path** as `Dockerfile`. | ||
| 4. Add environment variables: | ||
| * `DATABASE_URL`: Your Render Postgres connection string. | ||
| * `EXECUTE_MIGRATIONS`: `true` | ||
| * `NEXT_PUBLIC_MAPBOX_ACCESS_TOKEN`: Your Mapbox token. | ||
| * (Add other necessary API keys like Google, xAI, etc.) | ||
|
|
||
| ### Qdrant (Optional) | ||
| 1. Create a **New Private Service** or **Web Service**. | ||
| 2. Select **Docker** as the runtime. | ||
| 3. Use the image: `qdrant/qdrant:latest`. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Pin Qdrant image version for production. Line 53 uses 🤖 Prompt for AI Agents |
||
| 4. Set `QDRANT_URL` in your Web Service to point to this service. | ||
|
|
||
| --- | ||
|
|
||
| ## 3. Deploying to Google Cloud (GCP) | ||
|
|
||
| ### Cloud Run | ||
| 1. **Build and Push** the image to Google Artifact Registry: | ||
| ```bash | ||
| docker build -t gcr.io/YOUR_PROJECT/qcx . | ||
| docker push gcr.io/YOUR_PROJECT/qcx | ||
| ``` | ||
| 2. **Deploy to Cloud Run**: | ||
| ```bash | ||
| gcloud run deploy qcx --image gcr.io/YOUR_PROJECT/qcx --platform managed | ||
| ``` | ||
|
Comment on lines
+68
to
+69
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Cloud Run deployment command is incomplete for production. Line 68's
Additionally, Cloud Run is serverless and ephemeral—a direct 📋 Suggested improvements to Cloud Run deployment section2. **Deploy to Cloud Run**:
```bash
gcloud run deploy qcx \
--image gcr.io/YOUR_PROJECT/qcx \
--platform managed \
--region us-central1 \
--allow-unauthenticated \
--set-env-vars=DATABASE_URL=<YOUR_DATABASE_URL>,QDRANT_URL=<YOUR_QDRANT_URL>,NODE_ENV=production \
--memory 1Gi \
--cpu 1 \
--timeout 3600
```
3. **Set up Cloud SQL Proxy** (critical for connection pooling):
- Cloud Run cannot maintain long-lived connections to Cloud SQL.
- Use Cloud SQL Proxy or Supavisor to pool connections.
- Example: Use `cloud-sql-proxy` sidecar or configure DATABASE_URL with `?sslmode=require` and proper connection string routing.🤖 Prompt for AI Agents |
||
|
|
||
| ### Cloud SQL | ||
| 1. Create a **Cloud SQL for PostgreSQL** instance (version 15+). | ||
| 2. Cloud SQL supports both `pgvector` and `postgis`. Enable them via: | ||
| ```sql | ||
| CREATE EXTENSION IF NOT EXISTS postgis; | ||
| CREATE EXTENSION IF NOT EXISTS vector; | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ## 4. Vector Database Options | ||
|
|
||
| QCX is configured to support two vector database options: | ||
|
|
||
| 1. **PostgreSQL (pgvector)**: Integrated into the main database. Best for smaller datasets and simplicity. | ||
| 2. **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. | ||
|
|
||
| --- | ||
|
|
||
| ## 5. Security Checklist | ||
|
|
||
| * [ ] Change default passwords in `docker-compose.yaml`. | ||
| * [ ] Use SSL for database connections in production (`ssl=true` in `DATABASE_URL`). | ||
| * [ ] Set `NODE_ENV=production`. | ||
| * [ ] Ensure all sensitive API keys are stored as secrets, not committed to code. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| FROM postgres:16-alpine | ||
|
|
||
| # Install build dependencies and pgvector | ||
| RUN apk add --no-cache --virtual .build-deps \ | ||
| git \ | ||
| build-base \ | ||
| clang15 \ | ||
| llvm15-dev \ | ||
| postgis-dev \ | ||
| postgresql-dev \ | ||
| && git clone --branch v0.8.0 https://github.com/pgvector/pgvector.git /tmp/pgvector \ | ||
| && cd /tmp/pgvector \ | ||
| && make \ | ||
| && make install \ | ||
| && apk add --no-cache postgis \ | ||
| && rm -rf /tmp/pgvector \ | ||
| && apk del .build-deps | ||
|
|
||
| # Use the default entrypoint | ||
| ENTRYPOINT ["docker-entrypoint.sh"] | ||
| CMD ["postgres"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧹 Nitpick | 🔵 Trivial | 💤 Low value
Reorder environment variables to alphabetical order.
The static analysis tool (dotenv-linter) reports that
VERCEL_TEAM_ID(line 38) should appear beforeVERCEL_TOKEN(line 36) to maintain alphabetical/conventional ordering.🔧 Proposed reordering
📝 Committable suggestion
🧰 Tools
🪛 dotenv-linter (4.0.0)
[warning] 38-38: [UnorderedKey] The VERCEL_TEAM_ID key should go before the VERCEL_TOKEN key
(UnorderedKey)
🤖 Prompt for AI Agents
Source: Linters/SAST tools