feat: add browser support and Docker deployment

This commit is contained in:
2026-09-25 17:05:20 +02:00
parent 1d82aed1c4
commit e70ee0a01d
8 changed files with 173 additions and 14 deletions
+39
View File
@@ -18,6 +18,45 @@ source .venv/bin/activate or source .venv/bin/activate.fish
uv run main.py
```
## Browser / Docker deployment
The game runs client-side through [Pygbag](https://pygame-web.github.io/)
(Python WebAssembly + pygame-ce). Docker builds the web bundle and serves it
with non-root Nginx; players do not share a game session.
```bash
docker build -t silent-fh:web .
docker run -d --name silent-fh --restart unless-stopped -p 8080:8080 silent-fh:web
```
Open **http://localhost:8080**. Allow the initial runtime download to finish,
click the game/name field, enter a name, and press Enter. A desktop browser
with a keyboard is recommended; touch controls are not implemented.
Reload the page to start again after quitting the game.
Deployment notes:
- The container listens on **8080** and includes an HTTP healthcheck. Put it
behind your usual HTTPS reverse proxy for public hosting. No volumes needed.
- Both the image build and players' browsers need internet access. Pygbag's
versioned runtime and pygame-ce wheels are fetched from
`https://pygame-web.github.io/cdn/`; this is **not an offline/self-contained
runtime**. The container serves the game code and assets only.
- Browser highscores persist in `localStorage` per browser and site origin,
not on the server. Clearing site data clears scores; blocked storage falls
back to session-only scores. The desktop leaderboard is not published.
- Browser system fonts fall back to Pygame's bundled font. Audio may require
a click/key press before the browser permits playback.
- The native `uv run main.py` command still works. `Game.run()` is now async;
Python callers must await it.
Smoke checks (stdlib unittest, no extra test dependencies):
```bash
uv run python -m unittest discover -s tests -v
curl --fail http://localhost:8080/ > /dev/null
```
## Usage of the game:
- Use WASD or Arrow Keys to move around