#!/bin/bash

# Game Server Deployment Script

set -e

echo "🚀 Deploying Game Server to Modal..."

# Check if modal is installed
if ! command -v modal &> /dev/null; then
    echo "❌ Modal CLI not found. Installing..."
    pip install modal
fi

# Check if user is authenticated
if ! modal token show &> /dev/null; then
    echo "❌ Not authenticated with Modal. Please run:"
    echo "   modal token new"
    exit 1
fi

# Deploy the app
echo "📦 Deploying application..."
modal deploy main.py

echo ""
echo "✅ Deployment complete!"
echo ""
echo "📋 Next steps:"
echo "   1. Configure wildcard domain in Modal dashboard:"
echo "      https://modal.com/apps"
echo ""
echo "   2. Add custom domain: *.game-sites.suno.run"
echo ""
echo "   3. Update your DNS settings according to Modal's instructions"
echo ""
echo "   4. Test your deployment:"
echo "      curl https://ttunes.game-sites.suno.run"
echo ""
