rts-commander / docs /DEPLOYMENT.md
Luigi's picture
deploy(web): full clean snapshot with app code and assets
12d64f8
# RTS Game Web Application
## Quick Start for HuggingFace Spaces
This is a Dockerized web application ready for deployment on HuggingFace Spaces.
### Local Development
1. **Install dependencies**:
```bash
pip install -r requirements.txt
```
2. **Run the server**:
```bash
uvicorn app:app --host 0.0.0.0 --port 7860 --reload
```
3. **Open browser**: Navigate to `http://localhost:7860`
### Docker Build & Run
```bash
# Build the image
docker build -t rts-game .
# Run the container
docker run -p 7860:7860 rts-game
```
### Deployment to HuggingFace Spaces
1. Create a new Space on HuggingFace with Docker SDK
2. Upload all files from this directory
3. HuggingFace will automatically build and deploy using the Dockerfile
### Project Structure
```
web/
โ”œโ”€โ”€ app.py # FastAPI server with WebSocket
โ”œโ”€โ”€ Dockerfile # Container configuration
โ”œโ”€โ”€ requirements.txt # Python dependencies
โ”œโ”€โ”€ README.md # HuggingFace Space README
โ”œโ”€โ”€ static/
โ”‚ โ”œโ”€โ”€ index.html # Main game interface
โ”‚ โ”œโ”€โ”€ styles.css # Modern UI styling
โ”‚ โ””โ”€โ”€ game.js # Game client logic
```
### Features
- **Real-time gameplay** via WebSocket
- **Modern UI/UX** with responsive design
- **Minimap** with viewport indicator
- **Resource management** system
- **AI opponent** with intelligent behavior
- **Multiple unit types** and buildings
- **Drag-to-select** and command interface
### API Endpoints
- `GET /` - Main game interface
- `GET /health` - Health check endpoint
- `WS /ws` - WebSocket connection for game communication
### Game Commands (WebSocket)
```javascript
// Move units
{
type: "move_unit",
unit_ids: ["unit-id-1", "unit-id-2"],
target: { x: 100, y: 200 }
}
// Build unit
{
type: "build_unit",
building_id: "building-id",
unit_type: "tank"
}
// Place building
{
type: "build_building",
building_type: "barracks",
position: { x: 240, y: 240 },
player_id: 0
}
```
## Credits
Reimplemented from Python/Pygame to FastAPI/WebSocket for better web accessibility.