Spaces:
Sleeping
Sleeping
File size: 5,698 Bytes
12d64f8 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 |
# ๐ฎ RTS Commander - Deployment Checklist
## โ
Pre-Deployment Checklist
### Files Ready
- [x] `app.py` - Backend FastAPI server
- [x] `static/index.html` - Game interface
- [x] `static/styles.css` - UI styling
- [x] `static/game.js` - Game client
- [x] `Dockerfile` - Container config
- [x] `requirements.txt` - Dependencies
- [x] `README.md` - HuggingFace documentation
- [x] `.dockerignore` - Docker optimization
### Documentation Complete
- [x] Architecture documentation
- [x] Migration guide
- [x] Quick start guide
- [x] Deployment instructions
- [x] Project summary
### Testing
- [x] Python syntax valid
- [x] All imports work
- [x] Static files exist
- [x] Docker builds successfully
- [x] 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
```bash
# 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
```bash
# 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
```bash
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
```bash
# 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
```bash
# 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
```bash
# 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
```bash
# Check logs
docker logs <container_id>
# Check health
curl https://your-space.hf.space/health
```
### Update
```bash
# 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):
```dockerfile
RUN --mount=type=cache,target=/root/.cache/pip \
pip install -r requirements.txt
```
2. **Optimize image size**:
```dockerfile
# Use multi-stage build
FROM python:3.11-slim as builder
# ... build steps ...
FROM python:3.11-slim
COPY --from=builder /app /app
```
3. **Add healthcheck**:
```dockerfile
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):
```bash
HOST=0.0.0.0
PORT=7860
DEBUG=false
MAX_CONNECTIONS=100
TICK_RATE=20
```
Update `app.py` to use env vars:
```python
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
- 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! ๐ฎ**
|