Production Setup
Deploy Foundry in this order: Cloudflare Workers -> Convex -> Vercel -> Webhooks -> OAuth callbacks. Each step depends on URLs and secrets from the previous step.
Step 1: Deploy the Agent Worker (Cloudflare)
Section titled “Step 1: Deploy the Agent Worker (Cloudflare)”The agent worker handles AI analysis requests (requirement analysis, subtask generation, health scoring).
-
Install dependencies and deploy:
Terminal window cd agent-workerbun installwrangler deployNote the deployed URL:
https://foundry-agent-worker.<account>.workers.dev -
Set secrets:
Terminal window wrangler secret put ANTHROPIC_API_KEY# Paste your Anthropic API keywrangler secret put AGENT_SERVICE_SECRET# Generate: openssl rand -hex 32If using Atlassian integration:
Terminal window wrangler secret put ATLASSIAN_CLIENT_IDwrangler secret put ATLASSIAN_CLIENT_SECRETwrangler secret put ATLASSIAN_OAUTH_REDIRECT_URI# https://<your-domain>/api/atlassian/callback -
Verify the deployment:
Terminal window # Health check (no auth required)curl https://foundry-agent-worker.<account>.workers.dev/health# Auth check (should return 401)curl https://foundry-agent-worker.<account>.workers.dev/auth/status# Auth check with valid token (should return 200)curl -H "Authorization: Bearer <your-secret>" \https://foundry-agent-worker.<account>.workers.dev/auth/status
Step 2: Deploy the Sandbox Worker (Cloudflare)
Section titled “Step 2: Deploy the Sandbox Worker (Cloudflare)”The sandbox worker provisions ephemeral Docker containers for AI code execution.
-
Install dependencies and deploy:
Terminal window cd sandbox-workerbun installwrangler deployNote the deployed URL:
https://migration-sandbox-worker.<account>.workers.dev -
Set the shared API secret:
Terminal window wrangler secret put SANDBOX_API_SECRET# Must match the value you set in Convex (Step 3)
Step 3: Configure Convex (Production)
Section titled “Step 3: Configure Convex (Production)”-
Set environment variables in the Convex Dashboard (or via CLI):
Terminal window bunx convex env set AGENT_SERVICE_URL https://foundry-agent-worker.<account>.workers.devbunx convex env set AGENT_SERVICE_SECRET <same-secret-from-step-1>bunx convex env set ANTHROPIC_API_KEY <your-anthropic-key>bunx convex env set SANDBOX_WORKER_URL https://migration-sandbox-worker.<account>.workers.devbunx convex env set SANDBOX_API_SECRET <shared-sandbox-secret>bunx convex env set CLERK_WEBHOOK_SECRET <from-clerk-dashboard>bunx convex env set GITHUB_WEBHOOK_SECRET <your-github-hmac-secret>If using Atlassian:
Terminal window bunx convex env set ATLASSIAN_WEBHOOK_SECRET <your-atlassian-hmac-secret> -
Deploy Convex functions:
Terminal window bunx convex deployThis validates schema changes, runs migrations, and deploys all server functions.
Step 4: Deploy the Frontend (Vercel)
Section titled “Step 4: Deploy the Frontend (Vercel)”-
Connect your repository:
- Go to vercel.com/new and import your GitHub repository
- Framework Preset: Next.js (auto-detected)
- Root Directory:
apps/web - Build Command:
bun run build - Install Command:
bun install(runs at monorepo root) - Node.js Version: 20.x
-
Set public environment variables (available at build time):
Variable Value NEXT_PUBLIC_CONVEX_URLYour Convex deployment URL NEXT_PUBLIC_CLERK_PUBLISHABLE_KEYProduction Clerk publishable key NEXT_PUBLIC_GITHUB_APP_SLUGYour GitHub App slug NEXT_PUBLIC_CONVEX_SITE_URLProduction Convex site URL -
Set secret environment variables (server-side only):
Variable Value CLERK_SECRET_KEYProduction Clerk secret key CLERK_JWT_ISSUER_DOMAINProduction Clerk domain GITHUB_APP_IDYour GitHub App ID GITHUB_APP_PRIVATE_KEYRSA private key (full PEM) GITHUB_APP_CLIENT_IDOAuth client ID GITHUB_APP_CLIENT_SECRETOAuth client secret AGENT_SERVICE_URLAgent worker URL SANDBOX_WORKER_URLSandbox worker URL SANDBOX_API_SECRETShared sandbox secret If using Atlassian:
Variable Value ATLASSIAN_CLIENT_IDAtlassian OAuth client ID ATLASSIAN_CLIENT_SECRETAtlassian OAuth client secret ATLASSIAN_OAUTH_REDIRECT_URIhttps://<your-domain>/api/atlassian/callback -
Deploy:
Vercel deploys automatically on push to
main. For manual deploy:Terminal window cd apps/web && npx vercel --prod
Variables NOT needed on Vercel (these live in Convex Dashboard or Wrangler only): CONVEX_DEPLOYMENT, ANTHROPIC_API_KEY, AGENT_SERVICE_SECRET.
Custom domain (optional)
Section titled “Custom domain (optional)”- Go to Vercel project -> Settings -> Domains
- Add your domain
- Configure DNS:
- CNAME:
cname.vercel-dns.com(subdomain) - A records: Vercel IP addresses (apex domain)
- CNAME:
- SSL is auto-provisioned by Vercel
Step 5: Configure Webhooks
Section titled “Step 5: Configure Webhooks”All webhooks point to Convex Cloud HTTP endpoints, not Vercel.
| Service | Webhook URL | Secret Variable |
|---|---|---|
| Clerk | https://<convex-site-url>/clerk-webhook | CLERK_WEBHOOK_SECRET |
| GitHub | https://<convex-site-url>/api/webhooks/github | GITHUB_WEBHOOK_SECRET |
| Atlassian (Jira) | https://<convex-site-url>/api/webhooks/jira | ATLASSIAN_WEBHOOK_SECRET |
| Atlassian (Confluence) | https://<convex-site-url>/api/webhooks/confluence | ATLASSIAN_WEBHOOK_SECRET |
| Stripe | https://<convex-site-url>/api/webhooks/stripe | Stripe signing secret |
Step 6: Configure OAuth Callbacks
Section titled “Step 6: Configure OAuth Callbacks”Update callback URLs to point to your production domain:
GitHub App
Section titled “GitHub App”- GitHub -> Settings -> Developer settings -> GitHub Apps -> Your App
- Set Callback URL to:
https://<your-domain>/api/github/callback - Set Webhook URL to the Convex endpoint from Step 5
Atlassian App
Section titled “Atlassian App”- developer.atlassian.com -> Your App
- Set Callback URL to:
https://<your-domain>/api/atlassian/callback
- Clerk Dashboard -> Production instance
- Verify domain settings match your Vercel domain
- Set webhook endpoint to the Convex HTTP endpoint from Step 5
Verification checklist
Section titled “Verification checklist”Vercel
Section titled “Vercel”- Build succeeds on Vercel dashboard
- Landing page loads at production URL
- Clerk sign-in/sign-out works
- Organization switching works
- Convex data loads (real-time subscriptions active)
- GitHub OAuth callback works (
/api/github/callback) - Atlassian OAuth callback works (
/api/atlassian/callback)
Agent Worker
Section titled “Agent Worker”-
/healthreturns 200 - Unauthenticated requests return 401
- Bearer auth accepts valid token
-
/auth/statusshowsisConfigured: true
End-to-End
Section titled “End-to-End”- AI analysis triggers from production UI -> agent worker processes -> results appear in Convex
- Discovery analysis completes
- Task decomposition completes
- Sandbox execution provisions and runs
- Webhook events process (Clerk, GitHub, Atlassian)
- Sandbox auto-commits push to GitHub
Local Dev Still Works
Section titled “Local Dev Still Works”-
bun run devstarts Next.js on port 3000 -
bun run dev:convexstarts Convex dev -
bun run dev:agentstarts Express on port 3001 -
bun run dev:workerstarts sandbox worker on port 8788