DiceTales

DiceTales Deployment Guide

Complete guide for deploying DiceTales to various hosting platforms and environments.

🚀 Quick Deployment Options

Platform Difficulty Cost Best For
GitHub Pages Easy Free Open source projects
Netlify Easy Free Quick prototypes
Vercel Easy Free Modern deployments
Firebase Hosting Medium Free Google ecosystem
Self-Hosted Hard Variable Full control

📋 Pre-Deployment Checklist

Required Files

Ensure these files are present in your repository:

Configuration Check

Testing Checklist

🔧 GitHub Pages

Best for: Open source projects, free hosting, automatic updates

Setup Steps

  1. Prepare Repository
    git add .
    git commit -m "Prepare for deployment"
    git push origin main
    
  2. Enable GitHub Pages
    • Go to your repository on GitHub
    • Click SettingsPages
    • Under “Source”, select Deploy from a branch
    • Choose main branch and / (root) folder
    • Click Save
  3. Access Your Game
    • URL will be: https://yourusername.github.io/DiceTales/
    • Initial deployment takes 5-10 minutes

Custom Domain (Optional)

  1. Add CNAME file
    echo "yourdomain.com" > CNAME
    git add CNAME
    git commit -m "Add custom domain"
    git push
    
  2. Configure DNS
    • Add CNAME record: wwwyourusername.github.io
    • Add A records for apex domain:
      185.199.108.153
      185.199.109.153
      185.199.110.153
      185.199.111.153
      

GitHub Pages Configuration

# .github/workflows/pages.yml (optional - for advanced builds)
name: Deploy to GitHub Pages
on:
  push:
    branches: [ main ]
  workflow_dispatch:

permissions:
  contents: read
  pages: write
  id-token: write

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - name: Setup Pages
        uses: actions/configure-pages@v2
      - name: Upload artifact
        uses: actions/upload-pages-artifact@v1
        with:
          path: '.'
      - name: Deploy to GitHub Pages
        uses: actions/deploy-pages@v1

🌐 Netlify

Best for: Drag-and-drop deployment, build optimization, form handling

Method 1: Drag and Drop

  1. Visit netlify.com
  2. Sign up for free account
  3. Drag your DiceTales folder to the deploy area
  4. Get instant unique URL (e.g., https://amazing-name-123456.netlify.app)

Method 2: Git Integration

  1. Connect Repository
    • Login to Netlify
    • Click New site from Git
    • Choose GitHub/GitLab/Bitbucket
    • Select your DiceTales repository
  2. Build Settings
    Build command: # Leave empty (static site)
    Publish directory: . # Root directory
    
  3. Environment Variables (if needed)
    • Go to Site settingsEnvironment variables
    • Add any configuration variables

Netlify Configuration

Create netlify.toml in root directory:

[build]
  publish = "."
  command = ""

[[headers]]
  for = "/*"
  [headers.values]
    X-Frame-Options = "DENY"
    X-XSS-Protection = "1; mode=block"
    X-Content-Type-Options = "nosniff"
    Referrer-Policy = "strict-origin-when-cross-origin"

[[redirects]]
  from = "/*"
  to = "/index.html"
  status = 200
  condition = "Role=landing"

[context.production.environment]
  NODE_ENV = "production"

Custom Domain on Netlify

  1. Add Domain
    • Go to Site settingsDomain management
    • Click Add custom domain
    • Enter your domain name
  2. DNS Configuration
    • Add CNAME record: wwwyour-site-name.netlify.app
    • Or use Netlify’s nameservers for full DNS management

⚡ Vercel

Best for: Modern deployment, excellent performance, edge functions

Method 1: Vercel CLI

  1. Install Vercel CLI
    npm i -g vercel
    
  2. Deploy
    cd DiceTales
    vercel
    
  3. Follow Prompts
    • Link to existing project or create new
    • Confirm settings
    • Get deployment URL

Method 2: Git Integration

  1. Connect Repository
    • Visit vercel.com
    • Import your GitHub repository
    • Configure project settings
  2. Build Configuration
    {
      "version": 2,
      "builds": [
        {
          "src": "**/*",
          "use": "@vercel/static"
        }
      ]
    }
    

Vercel Configuration

Create vercel.json in root directory:

{
  "version": 2,
  "builds": [
    {
      "src": "**/*",
      "use": "@vercel/static"
    }
  ],
  "routes": [
    {
      "src": "/(.*)",
      "dest": "/$1"
    }
  ],
  "headers": [
    {
      "source": "/(.*)",
      "headers": [
        {
          "key": "X-Frame-Options",
          "value": "DENY"
        },
        {
          "key": "X-Content-Type-Options",
          "value": "nosniff"
        }
      ]
    }
  ]
}

🔥 Firebase Hosting

Best for: Google ecosystem integration, analytics, performance monitoring

Setup Steps

  1. Install Firebase CLI
    npm install -g firebase-tools
    
  2. Initialize Firebase
    cd DiceTales
    firebase login
    firebase init hosting
    
  3. Configuration
    // firebase.json
    {
      "hosting": {
        "public": ".",
        "ignore": [
          "firebase.json",
          "**/.*",
          "**/node_modules/**"
        ],
        "rewrites": [
          {
            "source": "**",
            "destination": "/index.html"
          }
        ]
      }
    }
    
  4. Deploy
    firebase deploy
    

Firebase Features

🏠 Self-Hosted

Best for: Full control, custom server configuration, enterprise deployments

Apache HTTP Server

  1. Upload Files
    scp -r DiceTales/* user@server:/var/www/html/dicetales/
    
  2. Apache Configuration
    # /etc/apache2/sites-available/dicetales.conf
    <VirtualHost *:80>
        ServerName dicetales.yourdomain.com
        DocumentRoot /var/www/html/dicetales
           
        <Directory /var/www/html/dicetales>
            AllowOverride All
            Require all granted
        </Directory>
           
        # Security headers
        Header always set X-Frame-Options DENY
        Header always set X-Content-Type-Options nosniff
        Header always set X-XSS-Protection "1; mode=block"
    </VirtualHost>
    
  3. Enable Site
    sudo a2ensite dicetales
    sudo systemctl reload apache2
    

Nginx

  1. Upload Files
    rsync -av DiceTales/ user@server:/var/www/dicetales/
    
  2. Nginx Configuration
    # /etc/nginx/sites-available/dicetales
    server {
        listen 80;
        server_name dicetales.yourdomain.com;
        root /var/www/dicetales;
        index index.html;
       
        location / {
            try_files $uri $uri/ =404;
        }
       
        # Security headers
        add_header X-Frame-Options DENY;
        add_header X-Content-Type-Options nosniff;
        add_header X-XSS-Protection "1; mode=block";
       
        # Cache static assets
        location ~* \.(css|js|png|jpg|jpeg|gif|ico|svg)$ {
            expires 1y;
            add_header Cache-Control "public, immutable";
        }
    }
    
  3. Enable Site
    sudo ln -s /etc/nginx/sites-available/dicetales /etc/nginx/sites-enabled/
    sudo nginx -t
    sudo systemctl reload nginx
    

Docker Deployment

  1. Create Dockerfile
    FROM nginx:alpine
    COPY . /usr/share/nginx/html
    EXPOSE 80
    CMD ["nginx", "-g", "daemon off;"]
    
  2. Build and Run
    docker build -t dicetales .
    docker run -d -p 8080:80 dicetales
    
  3. Docker Compose
    # docker-compose.yml
    version: '3.8'
    services:
      dicetales:
        build: .
        ports:
          - "8080:80"
        restart: unless-stopped
    

🔒 SSL/HTTPS Setup

Let’s Encrypt (Free SSL)

  1. Install Certbot
    sudo apt install certbot python3-certbot-nginx
    
  2. Obtain Certificate
    sudo certbot --nginx -d dicetales.yourdomain.com
    
  3. Auto-renewal
    sudo crontab -e
    # Add: 0 12 * * * /usr/bin/certbot renew --quiet
    

Cloudflare SSL

  1. Sign up for Cloudflare
  2. Add your domain
  3. Update nameservers
  4. Enable SSL in Cloudflare dashboard

📊 Performance Optimization

Content Delivery Network (CDN)

<!-- Add to index.html head -->
<link rel="preconnect" href="https://api-inference.huggingface.co">
<link rel="preload" href="advanced/css/main.css" as="style">
<link rel="preload" href="advanced/js/main.js" as="script">

Compression

# Apache .htaccess
<IfModule mod_deflate.c>
    AddOutputFilterByType DEFLATE text/plain
    AddOutputFilterByType DEFLATE text/html
    AddOutputFilterByType DEFLATE text/xml
    AddOutputFilterByType DEFLATE text/css
    AddOutputFilterByType DEFLATE application/xml
    AddOutputFilterByType DEFLATE application/xhtml+xml
    AddOutputFilterByType DEFLATE application/rss+xml
    AddOutputFilterByType DEFLATE application/javascript
    AddOutputFilterByType DEFLATE application/x-javascript
</IfModule>

Caching Headers

# Nginx configuration
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg)$ {
    expires 1y;
    add_header Cache-Control "public, immutable";
}

location ~* \.(html)$ {
    expires 1h;
    add_header Cache-Control "public, must-revalidate";
}

🔍 Monitoring and Analytics

Google Analytics Setup

  1. Add to index.html
    <!-- Google Analytics -->
    <script async src="https://www.googletagmanager.com/gtag/js?id=GA_MEASUREMENT_ID"></script>
    <script>
      window.dataLayer = window.dataLayer || [];
      function gtag(){dataLayer.push(arguments);}
      gtag('js', new Date());
      gtag('config', 'GA_MEASUREMENT_ID');
    </script>
    

Error Tracking

// Add to main.js
window.addEventListener('error', (event) => {
    console.error('Global error:', event.error);
    // Send to error tracking service
    if (typeof gtag !== 'undefined') {
        gtag('event', 'exception', {
            description: event.error.message,
            fatal: false
        });
    }
});

Performance Monitoring

// Track AI response times
const trackAIPerformance = (service, duration, success) => {
    if (typeof gtag !== 'undefined') {
        gtag('event', 'ai_response_time', {
            service: service,
            duration: Math.round(duration),
            success: success
        });
    }
};

🐛 Troubleshooting Deployment

Common Issues

“AI not working after deployment”

“Game won’t load”

“Styles not loading”

“Save/load not working”

Debug Mode

Enable debug mode for troubleshooting:

// In advanced/js/config.js
const AI_CONFIG = {
    DEBUG_MODE: true,          // Enable debug logging
    SHOW_AI_PROMPTS: true,     // Log AI requests
    LOG_PERFORMANCE: true      // Track performance metrics
};

Health Check Endpoint

Create health.html for monitoring:

<!DOCTYPE html>
<html>
<head>
    <title>DiceTales Health Check</title>
</head>
<body>
    <h1>DiceTales Status: OK</h1>
    <p>Timestamp: <span id="timestamp"></span></p>
    <script>
        document.getElementById('timestamp').textContent = new Date().toISOString();
    </script>
</body>
</html>

📈 Scaling Considerations

Traffic Optimization

High Availability

Cost Management


🎯 Next Steps

After successful deployment:

  1. Test thoroughly on the live site
  2. Monitor performance and user engagement
  3. Set up analytics to track usage
  4. Plan updates and new features
  5. Backup regularly and maintain documentation

Need help? Check the Technical Overview for architectural details or Setup Guide for local development.