rts-commander / docs /DEPLOYMENT_CHECKLIST.md
Luigi's picture
deploy(web): full clean snapshot with app code and assets
12d64f8

๐ŸŽฎ RTS Commander - Deployment Checklist

โœ… Pre-Deployment Checklist

Files Ready

  • app.py - Backend FastAPI server
  • static/index.html - Game interface
  • static/styles.css - UI styling
  • static/game.js - Game client
  • Dockerfile - Container config
  • requirements.txt - Dependencies
  • README.md - HuggingFace documentation
  • .dockerignore - Docker optimization

Documentation Complete

  • Architecture documentation
  • Migration guide
  • Quick start guide
  • Deployment instructions
  • Project summary

Testing

  • Python syntax valid
  • All imports work
  • Static files exist
  • Docker builds successfully
  • Local server runs

๐Ÿš€ HuggingFace Spaces Deployment

Step 1: Create Space

  1. Go to https://huggingface.co/spaces
  2. Click "Create new Space"
  3. Fill in:
    • Name: rts-commander (or your preferred name)
    • License: MIT
    • SDK: Docker โš ๏ธ IMPORTANT
    • Visibility: Public (or Private)

Step 2: Initialize Repository

# Clone the empty space
git clone https://huggingface.co/spaces/YOUR_USERNAME/rts-commander
cd rts-commander

# Copy all files from web/ directory
cp -r /path/to/rts/web/* .

# Verify files
ls -la

Step 3: Push to HuggingFace

# Add all files
git add .

# Commit
git commit -m "Initial commit: RTS Commander web game"

# Push to HuggingFace
git push origin main

Step 4: Wait for Build

  • HuggingFace will automatically detect Dockerfile
  • Build process takes 3-5 minutes
  • Watch logs in the Space settings

Step 5: Verify Deployment

  1. Open your Space URL: https://huggingface.co/spaces/YOUR_USERNAME/rts-commander
  2. Check /health endpoint
  3. Test WebSocket connection
  4. Play the game!

๐Ÿณ Docker Deployment (Alternative)

Build and Run Locally

cd web/

# Build Docker image
docker build -t rts-game .

# Run container
docker run -p 7860:7860 rts-game

# Test
open http://localhost:7860

Deploy to Cloud

Google Cloud Run

# Build and push
gcloud builds submit --tag gcr.io/PROJECT_ID/rts-game
gcloud run deploy rts-game --image gcr.io/PROJECT_ID/rts-game --platform managed

AWS ECS

# Build and push to ECR
aws ecr get-login-password --region region | docker login --username AWS --password-stdin aws_account_id.dkr.ecr.region.amazonaws.com
docker build -t rts-game .
docker tag rts-game:latest aws_account_id.dkr.ecr.region.amazonaws.com/rts-game:latest
docker push aws_account_id.dkr.ecr.region.amazonaws.com/rts-game:latest

Azure Container Instances

# Build and push to ACR
az acr build --registry myregistry --image rts-game .
az container create --resource-group myResourceGroup --name rts-game --image myregistry.azurecr.io/rts-game:latest --dns-name-label rts-game --ports 7860

๐Ÿ”ง Post-Deployment

Monitor

# Check logs
docker logs <container_id>

# Check health
curl https://your-space.hf.space/health

Update

# Make changes
vim app.py

# Commit and push
git add .
git commit -m "Update: description of changes"
git push origin main

๐Ÿ“Š Performance Optimization

For HuggingFace Spaces

  1. Enable caching (add to Dockerfile):
RUN --mount=type=cache,target=/root/.cache/pip \
    pip install -r requirements.txt
  1. Optimize image size:
# Use multi-stage build
FROM python:3.11-slim as builder
# ... build steps ...

FROM python:3.11-slim
COPY --from=builder /app /app
  1. Add healthcheck:
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
    CMD curl -f http://localhost:7860/health || exit 1

๐Ÿ› Troubleshooting

Build Fails

Problem: Docker build fails Solution: Check Dockerfile syntax and requirements.txt

WebSocket Connection Error

Problem: WebSocket won't connect Solution: Ensure port 7860 is exposed and server uses correct host (0.0.0.0)

Slow Performance

Problem: Game is laggy Solution:

  • Reduce game loop frequency
  • Optimize rendering
  • Use compression for WebSocket messages

Out of Memory

Problem: Container crashes Solution:

  • Reduce map size
  • Optimize data structures
  • Add memory limits in Dockerfile

๐Ÿ“ Configuration

Environment Variables

Create .env file (optional):

HOST=0.0.0.0
PORT=7860
DEBUG=false
MAX_CONNECTIONS=100
TICK_RATE=20

Update app.py to use env vars:

import os
HOST = os.getenv('HOST', '0.0.0.0')
PORT = int(os.getenv('PORT', 7860))

Custom Domain

For HuggingFace Spaces with custom domain:

  1. Go to Space settings
  2. Add custom domain
  3. Update DNS records
  4. Wait for SSL certificate

๐ŸŽฏ Next Steps After Deployment

  1. Share your Space

    • Tweet about it
    • Share on Discord
    • Post on Reddit
  2. Gather Feedback

    • Add feedback form
    • Monitor issues
    • Collect analytics
  3. Iterate

    • Fix bugs
    • Add features
    • Improve UI/UX
  4. Scale

    • Add multiplayer
    • Create tournaments
    • Build community

๐Ÿ“ž Support

HuggingFace Spaces Issues

Docker Issues

Game Issues

  • Check logs in browser console (F12)
  • Check server logs
  • Review documentation

โœจ Congratulations!

Your RTS game is now deployed and accessible to the world! ๐ŸŽ‰

Share it: https://huggingface.co/spaces/YOUR_USERNAME/rts-commander


Built with โค๏ธ - Happy gaming! ๐ŸŽฎ