#!/bin/bash # Setup Google Cloud Storage for Brainy Models CDN # This creates an immutable model hosting solution at models.soulcraft.com set -e echo "🧠 Setting up Brainy Models CDN on Google Cloud Storage" echo "========================================================" # Configuration PROJECT_ID="soulcraft-brain" BUCKET_NAME="models.soulcraft.com" MODELS_DIR="../../models" DOMAIN="models.soulcraft.com" # Check if models exist locally if [ ! -d "$MODELS_DIR/Xenova/all-MiniLM-L6-v2" ]; then echo "❌ Models not found. Run 'npm run download-models' first." exit 1 fi # Set the project echo "📍 Setting project: $PROJECT_ID" gcloud config set project $PROJECT_ID # Create the bucket (if it doesn't exist) echo "🪣 Creating GCS bucket: $BUCKET_NAME" gsutil mb -p $PROJECT_ID -c STANDARD -l US -b on gs://$BUCKET_NAME 2>/dev/null || echo "Bucket already exists" # Enable public access echo "🌍 Enabling public access..." gsutil iam ch allUsers:objectViewer gs://$BUCKET_NAME # Set CORS policy for browser access echo "🔧 Setting CORS policy..." cat > cors.json < manifest.json < index.html < Brainy Models CDN - Soulcraft

🧠 Brainy Models CDN ACTIVE

⚠️ CRITICAL: These models MUST NEVER CHANGE
They are the foundation of user data access. Any change would break existing embeddings and make user data inaccessible.

Transformer Model: all-MiniLM-L6-v2

This 384-dimensional transformer model is essential for Brainy's vector operations.

📦 Complete Package

all-MiniLM-L6-v2.tar.gz (87MB)
SHA256: $TARBALL_HASH

Individual Files:

Integration:

# Download and verify
curl -O https://models.soulcraft.com/models/all-MiniLM-L6-v2.tar.gz
echo "$TARBALL_HASH  all-MiniLM-L6-v2.tar.gz" | sha256sum -c

# Extract
tar -xzf all-MiniLM-L6-v2.tar.gz

API Endpoints:

  • GET /models/manifest.json - Model manifest with all hashes
  • GET /models/all-MiniLM-L6-v2.tar.gz - Complete model package
  • GET /models/Xenova/all-MiniLM-L6-v2/* - Individual model files

Features:

  • ✅ Immutable content (1-year cache headers)
  • ✅ SHA256 verification for integrity
  • ✅ Global CDN via Google Cloud
  • ✅ CORS enabled for browser access
  • ✅ 99.95% uptime SLA

Powered by Google Cloud Storage | View Manifest | GitHub

EOF gsutil -h "Cache-Control:public, max-age=3600" \ -h "Content-Type:text/html" \ cp index.html gs://$BUCKET_NAME/index.html # Set up website configuration echo "🌐 Configuring website settings..." gsutil web set -m index.html -e 404.html gs://$BUCKET_NAME # Create a load balancer (optional - for custom domain) echo "" echo "✅ GCS CDN setup complete!" echo "" echo "📍 Access your models at:" echo " https://storage.googleapis.com/$BUCKET_NAME/index.html" echo " https://storage.googleapis.com/$BUCKET_NAME/models/all-MiniLM-L6-v2.tar.gz" echo "" echo "To point models.soulcraft.com to this bucket:" echo "1. Add a CNAME record: models.soulcraft.com -> c.storage.googleapis.com" echo "2. Verify domain ownership in Google Cloud Console" echo "3. The bucket name must match the domain (models.soulcraft.com)" echo "" echo "Model hashes:" echo " Tarball: $TARBALL_HASH" echo " Model: $MODEL_HASH" echo "" echo "⚠️ Remember: These models must NEVER change!" # Cleanup rm cors.json manifest.json index.html rm $MODELS_DIR/all-MiniLM-L6-v2.tar.gz