feat(scripts): add Cloudflare setup and verification scripts
Add helper scripts for Cloudflare Pages and R2 deployment:
- cloudflare-setup.sh: Creates Pages project, deploys dist, creates R2 bucket
- verify-deployment.sh: End-to-end verification of all endpoints
These scripts require wrangler authentication via `wrangler login`.
Note: worker-api deployment removed from scope (legacy code was removed
in commit b06350d).
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
df3e59b9a9
commit
26244d1066
2 changed files with 121 additions and 0 deletions
66
scripts/cloudflare-setup.sh
Executable file
66
scripts/cloudflare-setup.sh
Executable file
|
|
@ -0,0 +1,66 @@
|
|||
#!/bin/bash
|
||||
# Cloudflare Setup Script for AI Code Battle
|
||||
# Run this script after authenticating with wrangler
|
||||
|
||||
set -e
|
||||
|
||||
echo "=== AI Code Battle - Cloudflare Setup ==="
|
||||
echo ""
|
||||
|
||||
# Check if wrangler is authenticated
|
||||
if ! ~/.local/bin/wrangler whoami &>/dev/null; then
|
||||
echo "ERROR: Not authenticated with Cloudflare."
|
||||
echo "Run: ~/.local/bin/wrangler login"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Authenticated as:"
|
||||
~/.local/bin/wrangler whoami
|
||||
echo ""
|
||||
|
||||
# Step 1: Create Pages project
|
||||
echo "=== Step 1: Creating Pages project 'aicodebattle' ==="
|
||||
if ~/.local/bin/wrangler pages project list 2>/dev/null | grep -q "aicodebattle"; then
|
||||
echo "Pages project 'aicodebattle' already exists."
|
||||
else
|
||||
echo "Creating Pages project..."
|
||||
~/.local/bin/wrangler pages project create aicodebattle --production-branch master
|
||||
fi
|
||||
echo ""
|
||||
|
||||
# Step 2: Deploy to Pages
|
||||
echo "=== Step 2: Deploying web/dist to Pages ==="
|
||||
~/.local/bin/wrangler pages deploy web/dist --project-name=aicodebattle --commit-dirty=true
|
||||
echo ""
|
||||
|
||||
# Step 3: Create R2 bucket
|
||||
echo "=== Step 3: Creating R2 bucket 'acb-data' ==="
|
||||
if ~/.local/bin/wrangler r2 bucket list 2>/dev/null | grep -q "acb-data"; then
|
||||
echo "R2 bucket 'acb-data' already exists."
|
||||
else
|
||||
echo "Creating R2 bucket..."
|
||||
~/.local/bin/wrangler r2 bucket create acb-data
|
||||
fi
|
||||
echo ""
|
||||
|
||||
echo "=== Automated setup complete! ==="
|
||||
echo ""
|
||||
echo "=== MANUAL STEPS REQUIRED (Cloudflare Dashboard) ==="
|
||||
echo ""
|
||||
echo "1. Configure Custom Domain for Pages:"
|
||||
echo " - Go to: Workers & Pages > aicodebattle > Settings > Custom domains"
|
||||
echo " - Add domain: aicodebattle.com"
|
||||
echo " - This auto-configures DNS CNAME"
|
||||
echo ""
|
||||
echo "2. Configure Custom Domain for R2:"
|
||||
echo " - Go to: R2 > acb-data > Settings > Custom Domains"
|
||||
echo " - Add domain: r2.aicodebattle.com"
|
||||
echo " - This auto-configures DNS CNAME"
|
||||
echo ""
|
||||
echo "3. Configure API DNS (requires Traefik LoadBalancer IP):"
|
||||
echo " - Go to: DNS > Records"
|
||||
echo " - Add A record: api.aicodebattle.com -> <Traefik IP> (proxied)"
|
||||
echo ""
|
||||
echo "4. Get Traefik IP from Kubernetes:"
|
||||
echo " kubectl --server=http://kubectl-apexalgo-iad:8001 get svc -n traefik"
|
||||
echo ""
|
||||
55
scripts/verify-deployment.sh
Executable file
55
scripts/verify-deployment.sh
Executable file
|
|
@ -0,0 +1,55 @@
|
|||
#!/bin/bash
|
||||
# Verify Cloudflare deployment end-to-end
|
||||
|
||||
set -e
|
||||
|
||||
echo "=== AI Code Battle - Deployment Verification ==="
|
||||
echo ""
|
||||
|
||||
# Colors for output
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
check_url() {
|
||||
local url=$1
|
||||
local name=$2
|
||||
if curl -sf -o /dev/null "$url"; then
|
||||
echo -e "${GREEN}✓${NC} $name: $url"
|
||||
return 0
|
||||
else
|
||||
echo -e "${RED}✗${NC} $name: $url"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
echo "Checking endpoints..."
|
||||
echo ""
|
||||
|
||||
# Check Pages (SPA)
|
||||
check_url "https://aicodebattle.com" "Pages (SPA)" || true
|
||||
|
||||
# Check R2 (replays) - just check the domain responds
|
||||
check_url "https://r2.aicodebattle.com" "R2 (custom domain)" || true
|
||||
|
||||
# Check API (K8s Traefik)
|
||||
check_url "https://api.aicodebattle.com/health" "API health" || true
|
||||
|
||||
echo ""
|
||||
echo "=== DNS Verification ==="
|
||||
echo ""
|
||||
|
||||
# DNS checks
|
||||
echo "aicodebattle.com:"
|
||||
dig +short aicodebattle.com || echo " (not configured)"
|
||||
|
||||
echo ""
|
||||
echo "r2.aicodebattle.com:"
|
||||
dig +short r2.aicodebattle.com || echo " (not configured)"
|
||||
|
||||
echo ""
|
||||
echo "api.aicodebattle.com:"
|
||||
dig +short api.aicodebattle.com || echo " (not configured)"
|
||||
|
||||
echo ""
|
||||
echo "=== Done ==="
|
||||
Loading…
Add table
Reference in a new issue