Skip to content

Latest commit

 

History

History
403 lines (297 loc) · 11 KB

File metadata and controls

403 lines (297 loc) · 11 KB

GraphDB Deployment Options for Syntopica

Date: 2025-11-24 Status: Ready to Deploy


Overview

You now have 3 options for deploying GraphDB staging environment:

Option Time Effort Flexibility Recommended For
1. Custom Image (Packer) 5 min Low Medium Production-like testing
2. Manual Deployment 2-3 hours High High Learning, customization
3. Docker (Marketplace) 10 min Low Low Quick testing

Option 1: Custom Image Deployment (Recommended ⭐)

Benefits

  • Fastest: 5 minutes from nothing to running server
  • 🔒 Consistent: Same configuration every time
  • 📦 Pre-built: GraphDB binary already compiled
  • 🚀 Scalable: Deploy multiple instances instantly
  • Tested: Image verified before use

Cost

  • Staging: $22/month (droplet $12 + volume $10)
  • Weekly backups: $7/month (4 weekly snapshots)
  • Image storage: $2.50/month (50GB snapshot)
  • Total: $31.50/month

Quick Start

# 1. Build image (one-time, ~15 minutes)
cd /home/ddowney/Workspace/github.com/graphdb/packer
export DIGITALOCEAN_API_TOKEN="your-token"
packer build graphdb-staging.pkr.hcl

# 2. Deploy from image (~5 minutes)
doctl compute droplet create graphdb-staging \
  --image <snapshot-id> \
  --size s-1vcpu-2gb \
  --region nyc1 \
  --ssh-keys <your-key>

# 3. Attach volume
doctl compute volume create graphdb-data --region nyc1 --size 100GiB
doctl compute volume-action attach <volume-id> <droplet-id>

# 4. SSH and mount
ssh root@<droplet-ip>
mkfs.ext4 -F /dev/disk/by-id/scsi-0DO_Volume_graphdb-data
mount -o discard,defaults /dev/disk/by-id/scsi-0DO_Volume_graphdb-data /mnt/graphdb-data
echo '/dev/disk/by-id/scsi-0DO_Volume_graphdb-data /mnt/graphdb-data ext4 defaults,nofail,discard 0 2' >> /etc/fstab
mkdir -p /mnt/graphdb-data/{data,wal,audit,backups}
chown -R graphdb:graphdb /mnt/graphdb-data

# 5. Start GraphDB
systemctl start graphdb
curl http://localhost:8080/health

# Done! 🎉

Documentation

  • Build guide: /home/ddowney/Workspace/github.com/graphdb/packer/README-CUSTOM-IMAGE.md
  • Packer template: /home/ddowney/Workspace/github.com/graphdb/packer/graphdb-staging.pkr.hcl

Option 2: Manual Deployment (Most Control)

Benefits

  • 🎛️ Full control: Customize every step
  • 📚 Educational: Learn how everything works
  • 🔧 Flexible: Easy to modify on the fly
  • 🐛 Debugging: Understand each component

Cost

  • Staging: $22/month (droplet $12 + volume $10)
  • Time investment: 2-3 hours first time, 30 min after practice

Quick Start

# Follow the comprehensive step-by-step guide
cat /home/ddowney/Workspace/github.com/graphdb/SYNTOPICA-STAGING-DEPLOYMENT.md

Documentation

  • Full deployment guide: /home/ddowney/Workspace/github.com/graphdb/SYNTOPICA-STAGING-DEPLOYMENT.md (1,020 lines)
  • Includes: Setup, configuration, monitoring, DR drill, troubleshooting

Option 3: Docker Deployment (Marketplace)

Benefits

  • 🐳 Containerized: Isolation and portability
  • 🛒 One-click: From DigitalOcean Marketplace (future)
  • 🔄 Easy updates: Pull new image
  • 📦 Self-contained: All dependencies in container

Cost

  • Staging: $22/month (droplet $12 + volume $10)
  • Overhead: Docker uses ~200MB RAM extra

Quick Start

# 1. Build marketplace image
cd /home/ddowney/Workspace/github.com/graphdb/packer
packer build graphdb.pkr.hcl

# 2. Deploy and use Docker Compose
ssh root@<droplet-ip>
cd /var/lib/graphdb
docker compose up -d

# Done!

Documentation

  • Marketplace template: /home/ddowney/Workspace/github.com/graphdb/packer/graphdb.pkr.hcl
  • Docker Compose: Included in image at /var/lib/graphdb/docker-compose.yml

Comparison Table

Feature Custom Image Manual Docker
Deployment Time 5 min 2-3 hours 10 min
Memory Overhead None None 200MB
Performance Native Native Container overhead
Flexibility Medium High Low
Scalability Excellent Manual Good
Updates Rebuild image Manual steps Pull image
Complexity Low High Low
Best For Production-like Learning Quick tests

Recommendation for Syntopica Staging

Use Option 1: Custom Image Deployment

Why:

  1. Speed: After initial 15-min build, deploy in 5 minutes

    • Perfect for 48-hour soak test iterations
    • Disaster recovery: spin up replacement in 60 seconds
  2. Consistency: Eliminates "works on my machine" issues

    • Same image for staging and production
    • Reproducible deployments
  3. Cost-effective: $2.50/month for image storage

    • Time saved: ~2-3 hours per deployment
    • After 2nd deployment, ROI is positive
  4. Scalability: Need more GraphDB instances?

    • Multi-region: Deploy to NYC, SFO, AMS instantly
    • Load balancing: Multiple instances behind Cloudflare
  5. Production-ready: This is how production systems are deployed

    • Netflix, Spotify, GitHub all use custom images
    • Industry best practice

Workflow:

# Week 1: Build image once
packer build graphdb-staging.pkr.hcl  # 15 minutes

# Weeks 2-52: Deploy instantly
doctl compute droplet create ... --image <snapshot-id>  # 60 seconds
# + 4 minutes for volume mount and start

# Test failed? Need fresh environment?
doctl compute droplet delete graphdb-staging-01
doctl compute droplet create graphdb-staging-01 --image <snapshot-id>
# Fresh environment in 5 minutes! 🚀

Decision Tree

Do you need GraphDB staging NOW (< 30 min)?
├─ YES: Have you built custom image already?
│  ├─ YES → Use Custom Image (5 min)
│  └─ NO → Use Docker (10 min), build custom image later
└─ NO: Want to learn or customize heavily?
   └─ YES → Use Manual Deployment (2-3 hours)

Next Steps: Building Custom Image

Phase 1: One-Time Setup (15 minutes)

# 1. Install Packer
brew install packer  # or download from packer.io

# 2. Install doctl
brew install doctl

# 3. Authenticate
doctl auth init  # Enter your DO API token
export DIGITALOCEAN_API_TOKEN="your-token"

# 4. Build image
cd /home/ddowney/Workspace/github.com/graphdb/packer
packer validate graphdb-staging.pkr.hcl
packer build graphdb-staging.pkr.hcl

# Wait ~15 minutes...
# Output: Snapshot ID (save this!)

Phase 2: Deploy Staging (5 minutes)

# 1. Create droplet from snapshot
doctl compute droplet create graphdb-staging \
  --image <snapshot-id> \
  --size s-1vcpu-2gb \
  --region nyc1 \
  --ssh-keys <your-key-id> \
  --enable-monitoring \
  --wait

# 2. Create and attach volume
doctl compute volume create graphdb-data --region nyc1 --size 100GiB
doctl compute volume-action attach <volume-id> <droplet-id>

# 3. Mount volume
ssh root@<droplet-ip>
mkfs.ext4 -F /dev/disk/by-id/scsi-0DO_Volume_graphdb-data
mount -o discard,defaults /dev/disk/by-id/scsi-0DO_Volume_graphdb-data /mnt/graphdb-data
echo '/dev/disk/by-id/scsi-0DO_Volume_graphdb-data /mnt/graphdb-data ext4 defaults,nofail,discard 0 2' >> /etc/fstab
mkdir -p /mnt/graphdb-data/{data,wal,audit,backups}
chown -R graphdb:graphdb /mnt/graphdb-data

# 4. Start services
systemctl start graphdb
systemctl status graphdb

# 5. Test
curl http://localhost:8080/health
# {"status":"healthy","uptime_seconds":5}

Phase 3: Cloudflare Tunnel (5 minutes)

# 1. Authenticate
cloudflared tunnel login

# 2. Create tunnel
cloudflared tunnel create graphdb-staging

# 3. Configure
vim /etc/cloudflared/config.yaml
# Update tunnel ID and hostname

# 4. Route DNS
cloudflared tunnel route dns graphdb-staging graphdb-staging.yourdomain.com

# 5. Start
systemctl start cloudflared
systemctl enable cloudflared

# 6. Test
curl https://graphdb-staging.yourdomain.com/health

Phase 4: Syntopica Integration (5 minutes)

# 1. Update Syntopica Workers
cd ~/Workspace/github.com/syntopica-v2/workers
npx wrangler secret put GRAPHDB_URL
# Enter: https://graphdb-staging.yourdomain.com

# 2. Deploy Workers
npx wrangler deploy --env staging

# 3. Sync data
curl -X POST https://staging.yourdomain.com/api/internal/sync/batch/all \
  -H "Authorization: Bearer $ADMIN_API_KEY"

# 4. Verify
curl https://graphdb-staging.yourdomain.com/stats | jq '.'
# {"nodes": 5000, "edges": 18000, ...}

Total time: 30 minutes (15 min build + 15 min deploy) Future deployments: 5 minutes (using existing image)


FAQ

Q: Can I use the custom image for production?

A: Yes! Just modify the Packer template:

  • Change size from s-1vcpu-2gb to s-2vcpu-4gb
  • Update environment variable to production
  • Build new image: packer build -var="environment=production" graphdb-staging.pkr.hcl

Q: How do I update GraphDB in the image?

A: Rebuild the image:

cd ~/Workspace/github.com/graphdb
git pull  # Get latest changes
cd packer
packer build graphdb-staging.pkr.hcl
# New snapshot created with latest code

Q: Can I customize the image before building?

A: Yes! Edit the Packer template:

  • Modify configuration templates in packer/config/
  • Add provisioning steps in graphdb-staging.pkr.hcl
  • Update scripts in packer/scripts/

Q: What if I need to deploy to multiple regions?

A: Update snapshot_regions in Packer template:

snapshot_regions = ["nyc1", "sfo3", "ams3", "lon1"]

Rebuild image - snapshot replicated to all regions automatically.

Q: How much does the custom image cost?

A:

  • Snapshot storage: $0.05/GB/month
  • 50GB image = $2.50/month
  • Each additional region snapshot = $2.50/month
  • Build time: $0.03 (15 min of temporary droplet)

Total: ~$2.50/month for single-region, ~$10/month for 4 regions


All Documentation Files

  1. DEPLOYMENT-OPTIONS.md (this file) - Overview of all options
  2. SYNTOPICA-STAGING-DEPLOYMENT.md - Manual deployment guide (1,020 lines)
  3. packer/README-CUSTOM-IMAGE.md - Custom image guide
  4. packer/graphdb-staging.pkr.hcl - Staging image template
  5. packer/graphdb.pkr.hcl - Marketplace/Docker image template
  6. FUZZING-E2E-SUMMARY.md - Testing improvements summary
  7. GOCERT-VERIFICATION-REPORT.md - Formal verification findings
  8. GOCERT-FIX-SUMMARY.md - Critical bug fix summary

Summary

You're ready to deploy GraphDB staging!

Fastest path to running system:

  1. Build custom image: 15 minutes
  2. Deploy to DigitalOcean: 5 minutes
  3. Setup Cloudflare Tunnel: 5 minutes
  4. Integrate Syntopica: 5 minutes
  5. Total: 30 minutes to fully operational staging environment

Then:

  • Run 48-hour soak test with real Syntopica workload
  • Perform DR drill (backup/restore)
  • Validate production readiness

Production readiness: 75% → 80%+ after soak test and DR drill ✅


Ready to start?

cd /home/ddowney/Workspace/github.com/graphdb/packer
cat README-CUSTOM-IMAGE.md  # Read the guide
packer build graphdb-staging.pkr.hcl  # Build the image!

Author: Claude Code Last Updated: 2025-11-24 Status: Ready to Deploy 🚀