Cloudflare Pages Deployment
Deploy Uranus to Cloudflare's edge network.
Prerequisites
- Cloudflare account with Workers Paid plan (recommended)
- Node.js 18+
- Wrangler CLI
Quick Deploy
1. Clone and Install
bash
git clone https://github.com/anthropics/uranus.git
cd uranus/manage
npm install2. Login to Cloudflare
bash
npx wrangler login3. Create Resources
bash
# Create D1 database
npx wrangler d1 create agents-dashboard
# Create R2 bucket
npx wrangler r2 bucket create agents-dashboard-files
# Create Vectorize index
npx wrangler vectorize create agents-dashboard-embeddings \
--dimensions=768 \
--metric=cosine4. Configure wrangler.toml
Update with your resource IDs:
toml
name = "cloudflare-agents-pages"
main = "src/worker.ts"
compatibility_date = "2024-12-05"
compatibility_flags = ["nodejs_compat"]
[build]
command = "npm run build"
[site]
bucket = "./dist"
[[d1_databases]]
binding = "DB"
database_name = "agents-dashboard"
database_id = "YOUR_DATABASE_ID"
[[r2_buckets]]
binding = "BUCKET"
bucket_name = "agents-dashboard-files"
[[vectorize]]
binding = "VECTORIZE"
index_name = "agents-dashboard-embeddings"
[[durable_objects.bindings]]
name = "AGENT"
class_name = "DashboardAgent"
[[migrations]]
tag = "v1"
new_classes = ["DashboardAgent"]
[[queues.producers]]
binding = "WORKFLOWS_QUEUE"
queue = "agents-dashboard-workflows"
[[queues.consumers]]
queue = "agents-dashboard-workflows"
max_batch_size = 10
max_batch_timeout = 30
[vars]
ENVIRONMENT = "production"5. Apply Migrations
bash
# Main schema
npx wrangler d1 execute agents-dashboard --file=./schema.sql
# Migrations
npx wrangler d1 execute agents-dashboard --file=./migrations/002_multi_agent.sql
npx wrangler d1 execute agents-dashboard --file=./migrations/003_agent_auth.sql
npx wrangler d1 execute agents-dashboard --file=./migrations/004_workflow_executions.sql
npx wrangler d1 execute agents-dashboard --file=./migrations/005_cloudflare_settings.sql
npx wrangler d1 execute agents-dashboard --file=./migrations/006_browser_actions_types.sql
npx wrangler d1 execute agents-dashboard --file=./migrations/007_puppeteer_action_types.sql6. Deploy
bash
npm run deployCloudflare Resources
D1 Database
SQLite database at the edge:
toml
[[d1_databases]]
binding = "DB"
database_name = "agents-dashboard"
database_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"R2 Storage
Object storage for files:
toml
[[r2_buckets]]
binding = "BUCKET"
bucket_name = "agents-dashboard-files"Vectorize
Vector database for embeddings:
toml
[[vectorize]]
binding = "VECTORIZE"
index_name = "agents-dashboard-embeddings"Durable Objects
Stateful compute:
toml
[[durable_objects.bindings]]
name = "AGENT"
class_name = "DashboardAgent"
[[migrations]]
tag = "v1"
new_classes = ["DashboardAgent"]Queues
Async task processing:
toml
[[queues.producers]]
binding = "WORKFLOWS_QUEUE"
queue = "agents-dashboard-workflows"
[[queues.consumers]]
queue = "agents-dashboard-workflows"CI/CD Pipeline
GitHub Actions
yaml
name: Deploy
on:
push:
branches: [main]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install dependencies
run: npm ci
- name: Build
run: npm run build
- name: Deploy
uses: cloudflare/wrangler-action@v3
with:
apiToken: ${{ secrets.CF_API_TOKEN }}
accountId: ${{ secrets.CF_ACCOUNT_ID }}
command: deployRequired Secrets
| Secret | Description |
|---|---|
CF_API_TOKEN | Cloudflare API token |
CF_ACCOUNT_ID | Cloudflare account ID |
Production Configuration
Environment Variables
toml
[vars]
ENVIRONMENT = "production"
# Optional: Browserbase
BROWSERBASE_PROJECT_ID = ""
BROWSERBASE_API_KEY = ""
# Optional: Cloudflare Access
CF_ACCESS_AUD = ""Workers Paid Features
Recommended for production:
- Unmetered requests
- Longer CPU time
- Durable Objects
- Queues
- Analytics
Monitoring
Cloudflare Dashboard
Monitor via Cloudflare dashboard:
- Request analytics
- Error rates
- CPU time
- Durable Object metrics
Logging
View logs:
bash
npx wrangler tailMetrics
Enable Workers Analytics:
toml
[observability]
enabled = trueScaling
Uranus automatically scales on Cloudflare:
- Edge deployment worldwide
- Automatic scaling
- No cold starts (Durable Objects)
- Pay-per-request
Troubleshooting
Deployment Failed
bash
# Check build
npm run build
# Verify wrangler config
npx wrangler whoami
# View detailed errors
npx wrangler deploy --verboseD1 Connection Issues
bash
# Verify database
npx wrangler d1 list
# Test query
npx wrangler d1 execute agents-dashboard --command "SELECT 1"Durable Object Errors
bash
# View DO logs
npx wrangler tail --filter "DO"
# Check migrations
npx wrangler migrations listRollback
Previous Version
bash
npx wrangler rollbackSpecific Version
bash
npx wrangler rollback --version 12345Security
Cloudflare Access
Enable SSO:
- Go to Cloudflare Access
- Create application
- Configure identity provider
- Set CF_ACCESS_AUD in wrangler.toml
API Security
- Rate limiting enabled
- CORS configured
- HTTPS enforced
Cost Optimization
Free Tier Limits
| Resource | Limit |
|---|---|
| Workers Requests | 100K/day |
| D1 Reads | 5M/day |
| D1 Writes | 100K/day |
| R2 Class A | 1M/month |
| R2 Class B | 10M/month |
Paid Tier
Consider Workers Paid ($5/month):
- 10M requests included
- Durable Objects
- Queues
- Longer CPU time