Spaces:
Sleeping
Sleeping
๐ฎ 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
- Go to https://huggingface.co/spaces
- Click "Create new Space"
- Fill in:
- Name:
rts-commander(or your preferred name) - License:
MIT - SDK:
Dockerโ ๏ธ IMPORTANT - Visibility: Public (or Private)
- Name:
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
- Open your Space URL:
https://huggingface.co/spaces/YOUR_USERNAME/rts-commander - Check
/healthendpoint - Test WebSocket connection
- 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
- Enable caching (add to Dockerfile):
RUN --mount=type=cache,target=/root/.cache/pip \
pip install -r requirements.txt
- 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
- 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:
- Go to Space settings
- Add custom domain
- Update DNS records
- Wait for SSL certificate
๐ฏ Next Steps After Deployment
Share your Space
- Tweet about it
- Share on Discord
- Post on Reddit
Gather Feedback
- Add feedback form
- Monitor issues
- Collect analytics
Iterate
- Fix bugs
- Add features
- Improve UI/UX
Scale
- Add multiplayer
- Create tournaments
- Build community
๐ Support
HuggingFace Spaces Issues
- Forum: https://discuss.huggingface.co/
- Discord: https://discord.gg/huggingface
Docker Issues
- Documentation: https://docs.docker.com/
- Stack Overflow: https://stackoverflow.com/questions/tagged/docker
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! ๐ฎ