mirror of
https://github.com/cdr/code-server.git
synced 2026-01-25 01:22:58 +01:00
feat: Configure Cloudflare KV namespaces and add deployment scripts
Co-authored-by: fekofal332 <fekofal332@reaxu.com>
This commit is contained in:
parent
d4e6c92e49
commit
4f65853a54
4 changed files with 283 additions and 6 deletions
133
cursor-fullstack/CLOUDFLARE_DEPLOYMENT_STATUS.md
Normal file
133
cursor-fullstack/CLOUDFLARE_DEPLOYMENT_STATUS.md
Normal file
|
|
@ -0,0 +1,133 @@
|
|||
# Cloudflare Deployment Status
|
||||
|
||||
## 🔍 Current Situation
|
||||
|
||||
The provided API token `hRLCKWr1enn1_qvQlpQJjEuSbIZ13LpoKHo-v5nF` has been successfully used to:
|
||||
|
||||
✅ **Successfully Created:**
|
||||
- KV Namespace: `API_KEYS` (ID: `2a705b445979465ca3d65b117b90411a`)
|
||||
- KV Namespace: `FILE_STORAGE_KV` (ID: `cae71ccff3df4039996865e01758f53f`)
|
||||
- KV Namespace: `SESSIONS` (ID: `cfc6ab0d08e24421bb602b2d96f5b8ac`)
|
||||
|
||||
❌ **Failed to Create:**
|
||||
- R2 Bucket: `cursor-files` (Error: R2 not enabled in account)
|
||||
|
||||
❌ **Failed to Deploy:**
|
||||
- Workers deployment (Error: Insufficient API token permissions)
|
||||
- Pages deployment (Error: Insufficient API token permissions)
|
||||
|
||||
## 🔧 Issues Identified
|
||||
|
||||
### 1. **API Token Permissions**
|
||||
The provided API token has limited permissions and cannot:
|
||||
- Deploy Workers
|
||||
- Deploy to Pages
|
||||
- Create R2 buckets
|
||||
|
||||
### 2. **R2 Service Not Enabled**
|
||||
The Cloudflare account needs R2 to be enabled through the dashboard.
|
||||
|
||||
## 🚀 Solutions
|
||||
|
||||
### Option 1: Update API Token Permissions
|
||||
The current API token needs additional permissions. Please create a new API token with:
|
||||
|
||||
**Required Permissions:**
|
||||
- `Cloudflare Workers:Edit`
|
||||
- `Cloudflare Pages:Edit`
|
||||
- `Account:Read`
|
||||
- `Zone:Read`
|
||||
|
||||
**Required Resources:**
|
||||
- `Account:Thailand.2528hho@gmail.com's Account`
|
||||
|
||||
### Option 2: Manual Deployment via Dashboard
|
||||
1. **Enable R2 Service:**
|
||||
- Go to Cloudflare Dashboard
|
||||
- Navigate to R2 Object Storage
|
||||
- Enable R2 service
|
||||
|
||||
2. **Create R2 Bucket:**
|
||||
- Create bucket named `cursor-files`
|
||||
|
||||
3. **Deploy Workers:**
|
||||
- Go to Workers & Pages
|
||||
- Create new Worker
|
||||
- Upload the backend code from `cloudflare/backend/`
|
||||
|
||||
4. **Deploy Pages:**
|
||||
- Go to Pages
|
||||
- Create new project
|
||||
- Upload the built frontend from `cloudflare/frontend/dist/`
|
||||
|
||||
### Option 3: Use Wrangler Login
|
||||
```bash
|
||||
# Clear current token
|
||||
unset CLOUDFLARE_API_TOKEN
|
||||
|
||||
# Login interactively
|
||||
wrangler login
|
||||
|
||||
# Deploy
|
||||
wrangler deploy
|
||||
```
|
||||
|
||||
## 📋 Current Configuration
|
||||
|
||||
The `wrangler.toml` file has been updated with the actual KV namespace IDs:
|
||||
|
||||
```toml
|
||||
[[kv_namespaces]]
|
||||
binding = "API_KEYS"
|
||||
id = "2a705b445979465ca3d65b117b90411a"
|
||||
preview_id = "2a705b445979465ca3d65b117b90411a"
|
||||
|
||||
[[kv_namespaces]]
|
||||
binding = "FILE_STORAGE_KV"
|
||||
id = "cae71ccff3df4039996865e01758f53f"
|
||||
preview_id = "cae71ccff3df4039996865e01758f53f"
|
||||
|
||||
[[kv_namespaces]]
|
||||
binding = "SESSIONS"
|
||||
id = "cfc6ab0d08e24421bb602b2d96f5b8ac"
|
||||
preview_id = "cfc6ab0d08e24421bb602b2d96f5b8ac"
|
||||
```
|
||||
|
||||
## 🎯 Next Steps
|
||||
|
||||
1. **Enable R2 Service** in Cloudflare Dashboard
|
||||
2. **Create new API token** with full permissions, OR
|
||||
3. **Use interactive login** with `wrangler login`
|
||||
4. **Deploy the application** using the provided scripts
|
||||
|
||||
## 📁 Ready for Deployment
|
||||
|
||||
All code is ready and properly configured:
|
||||
- ✅ Backend code fixed and ready
|
||||
- ✅ Frontend built successfully
|
||||
- ✅ Configuration files updated
|
||||
- ✅ KV namespaces created
|
||||
- ✅ Deployment scripts prepared
|
||||
|
||||
The only remaining step is to resolve the API token permissions issue.
|
||||
|
||||
## 🔗 Useful Commands
|
||||
|
||||
Once permissions are resolved:
|
||||
|
||||
```bash
|
||||
# Deploy backend
|
||||
cd cloudflare
|
||||
wrangler deploy
|
||||
|
||||
# Deploy frontend
|
||||
cd cloudflare/frontend
|
||||
wrangler pages deploy dist --project-name cursor-ide
|
||||
```
|
||||
|
||||
## 📞 Support
|
||||
|
||||
If you need help with API token permissions or R2 enablement, please:
|
||||
1. Check the Cloudflare Dashboard for R2 enablement
|
||||
2. Create a new API token with full permissions
|
||||
3. Or use `wrangler login` for interactive authentication
|
||||
91
cursor-fullstack/cloudflare/deploy-with-token.sh
Executable file
91
cursor-fullstack/cloudflare/deploy-with-token.sh
Executable file
|
|
@ -0,0 +1,91 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Deploy to Cloudflare with API Token
|
||||
set -e
|
||||
|
||||
# Colors
|
||||
GREEN='\033[0;32m'
|
||||
BLUE='\033[0;34m'
|
||||
YELLOW='\033[1;33m'
|
||||
RED='\033[0;31m'
|
||||
NC='\033[0m'
|
||||
|
||||
echo -e "${BLUE}"
|
||||
echo "=========================================="
|
||||
echo " 🚀 Cursor Full Stack AI IDE"
|
||||
echo " 📦 Deploy with API Token"
|
||||
echo "=========================================="
|
||||
echo -e "${NC}"
|
||||
|
||||
# Check if API token is provided
|
||||
if [ -z "$CLOUDFLARE_API_TOKEN" ]; then
|
||||
echo -e "${RED}Error: CLOUDFLARE_API_TOKEN environment variable is not set${NC}"
|
||||
echo "Please set your API token:"
|
||||
echo "export CLOUDFLARE_API_TOKEN=your_token_here"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo -e "${GREEN}✅ API Token is set${NC}"
|
||||
|
||||
# Check authentication
|
||||
echo -e "${YELLOW}Checking authentication...${NC}"
|
||||
if ! wrangler whoami &> /dev/null; then
|
||||
echo -e "${RED}❌ Authentication failed${NC}"
|
||||
echo "Please check your API token permissions"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo -e "${GREEN}✅ Authenticated successfully${NC}"
|
||||
|
||||
# Deploy backend
|
||||
echo -e "${YELLOW}Deploying backend...${NC}"
|
||||
if wrangler deploy --env=""; then
|
||||
echo -e "${GREEN}✅ Backend deployed successfully${NC}"
|
||||
else
|
||||
echo -e "${RED}❌ Backend deployment failed${NC}"
|
||||
echo "This might be due to insufficient API token permissions"
|
||||
echo "Please check that your token has 'Cloudflare Workers:Edit' permission"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Build and deploy frontend
|
||||
echo -e "${YELLOW}Building frontend...${NC}"
|
||||
cd frontend
|
||||
npm run build
|
||||
echo -e "${GREEN}✅ Frontend built successfully${NC}"
|
||||
|
||||
echo -e "${YELLOW}Deploying frontend to Pages...${NC}"
|
||||
if wrangler pages deploy dist --project-name cursor-ide; then
|
||||
echo -e "${GREEN}✅ Frontend deployed successfully${NC}"
|
||||
else
|
||||
echo -e "${RED}❌ Frontend deployment failed${NC}"
|
||||
echo "This might be due to insufficient API token permissions"
|
||||
echo "Please check that your token has 'Cloudflare Pages:Edit' permission"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cd ..
|
||||
|
||||
echo -e "\n${GREEN}=========================================="
|
||||
echo " 🎉 DEPLOYMENT COMPLETE! 🎉"
|
||||
echo "=========================================="
|
||||
echo -e "${NC}"
|
||||
|
||||
echo -e "${GREEN}✅ Backend deployed successfully${NC}"
|
||||
echo -e " URL: https://cursor-backend.workers.dev"
|
||||
echo -e " WebSocket: wss://cursor-backend.workers.dev"
|
||||
echo -e " Health: https://cursor-backend.workers.dev/health"
|
||||
|
||||
echo -e "\n${GREEN}✅ Frontend deployed successfully${NC}"
|
||||
echo -e " URL: https://cursor-ide.pages.dev"
|
||||
|
||||
echo -e "\n${YELLOW}📋 Next Steps:${NC}"
|
||||
echo -e "1. 🌐 Open your application: https://cursor-ide.pages.dev"
|
||||
echo -e "2. 🔑 Configure your AI provider API keys in the settings"
|
||||
echo -e "3. 🧪 Test the application functionality"
|
||||
echo -e "4. 📊 Monitor performance in Cloudflare Dashboard"
|
||||
|
||||
echo -e "\n${GREEN}=========================================="
|
||||
echo " 🚀 Your AI IDE is now live! 🚀"
|
||||
echo "=========================================="
|
||||
echo -e "${NC}"
|
||||
53
cursor-fullstack/cloudflare/setup-cloudflare.sh
Executable file
53
cursor-fullstack/cloudflare/setup-cloudflare.sh
Executable file
|
|
@ -0,0 +1,53 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Setup Cloudflare services using API
|
||||
set -e
|
||||
|
||||
API_TOKEN="hRLCKWr1enn1_qvQlpQJjEuSbIZ13LpoKHo-v5nF"
|
||||
ACCOUNT_ID="76f5b050419f112f1e9c5fbec1b3970d"
|
||||
|
||||
echo "Setting up Cloudflare services..."
|
||||
|
||||
# Create KV Namespaces
|
||||
echo "Creating KV Namespaces..."
|
||||
|
||||
# API_KEYS namespace
|
||||
echo "Creating API_KEYS namespace..."
|
||||
API_KEYS_RESPONSE=$(curl -s -X POST "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/storage/kv/namespaces" \
|
||||
-H "Authorization: Bearer $API_TOKEN" \
|
||||
-H "Content-Type: application/json" \
|
||||
--data '{"title":"API_KEYS"}')
|
||||
|
||||
echo "API_KEYS Response: $API_KEYS_RESPONSE"
|
||||
|
||||
# FILE_STORAGE_KV namespace
|
||||
echo "Creating FILE_STORAGE_KV namespace..."
|
||||
FILE_STORAGE_RESPONSE=$(curl -s -X POST "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/storage/kv/namespaces" \
|
||||
-H "Authorization: Bearer $API_TOKEN" \
|
||||
-H "Content-Type: application/json" \
|
||||
--data '{"title":"FILE_STORAGE_KV"}')
|
||||
|
||||
echo "FILE_STORAGE_KV Response: $FILE_STORAGE_RESPONSE"
|
||||
|
||||
# SESSIONS namespace
|
||||
echo "Creating SESSIONS namespace..."
|
||||
SESSIONS_RESPONSE=$(curl -s -X POST "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/storage/kv/namespaces" \
|
||||
-H "Authorization: Bearer $API_TOKEN" \
|
||||
-H "Content-Type: application/json" \
|
||||
--data '{"title":"SESSIONS"}')
|
||||
|
||||
echo "SESSIONS Response: $SESSIONS_RESPONSE"
|
||||
|
||||
# Create R2 Buckets
|
||||
echo "Creating R2 Buckets..."
|
||||
|
||||
# cursor-files bucket
|
||||
echo "Creating cursor-files bucket..."
|
||||
R2_RESPONSE=$(curl -s -X POST "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/r2/buckets" \
|
||||
-H "Authorization: Bearer $API_TOKEN" \
|
||||
-H "Content-Type: application/json" \
|
||||
--data '{"name":"cursor-files"}')
|
||||
|
||||
echo "R2 Response: $R2_RESPONSE"
|
||||
|
||||
echo "Setup complete!"
|
||||
|
|
@ -22,18 +22,18 @@ new_classes = [ "WebSocketDurableObject" ]
|
|||
# KV Storage for API keys and session data
|
||||
[[kv_namespaces]]
|
||||
binding = "API_KEYS"
|
||||
id = "placeholder-api-keys-id"
|
||||
preview_id = "placeholder-api-keys-preview-id"
|
||||
id = "2a705b445979465ca3d65b117b90411a"
|
||||
preview_id = "2a705b445979465ca3d65b117b90411a"
|
||||
|
||||
[[kv_namespaces]]
|
||||
binding = "FILE_STORAGE_KV"
|
||||
id = "placeholder-file-storage-kv-id"
|
||||
preview_id = "placeholder-file-storage-kv-preview-id"
|
||||
id = "cae71ccff3df4039996865e01758f53f"
|
||||
preview_id = "cae71ccff3df4039996865e01758f53f"
|
||||
|
||||
[[kv_namespaces]]
|
||||
binding = "SESSIONS"
|
||||
id = "placeholder-sessions-id"
|
||||
preview_id = "placeholder-sessions-preview-id"
|
||||
id = "cfc6ab0d08e24421bb602b2d96f5b8ac"
|
||||
preview_id = "cfc6ab0d08e24421bb602b2d96f5b8ac"
|
||||
|
||||
# R2 Storage for file storage
|
||||
[[r2_buckets]]
|
||||
|
|
|
|||
Loading…
Reference in a new issue