Skip to content

About

Rust referee and sandbox supervisor for Codebattle Vibe Tournaments

Resources

Stars

2 stars

Watchers

0 watching

Forks

Repository files navigation

VibeBattle

VibeBattle is the Rust server that runs Python bot matches and produces replays for Codebattle.

Docker in development

From the repository root, build the image and run it on localhost:4007:

docker build -t vibebattle:dev .
docker run --rm --init --read-only --cap-drop ALL \
  --security-opt no-new-privileges -p 127.0.0.1:4007:4007 \
  -e VIBE_RUNNER_TOKEN=vibebattle-local-development-token \
  vibebattle:dev

With jq installed, run mise run match for Depot Dash or mise run match-snakes for Snake Arena from another terminal. Run mise run test-container to build the test image and exercise both games inside it. For Podman, set CONTAINER_ENGINE=podman when running the test task. For Rust development, mise install sets up Rust and mise run test runs the Rust suite.

Docker in production

GitHub Actions publishes the container image to GHCR for Linux on AMD64 and ARM64. Macs run it through a Linux VM.

The image includes CPython 3.13. Each bot runs as a separate Wasmtime process with bounded memory, CPU time, and turn time. Bots receive game observations and read-only Python libraries. Native extensions, subprocesses, and network access are unavailable. A failed bot forfeits its seat in a ranked match.

Set VIBE_IMAGE in your shell to the published image pinned by digest or sha-<commit> tag. In /etc/vibebattle/runner.env, set VIBE_RUNNER_TOKEN to a random secret of at least 32 bytes and VIBE_MATCH_SLOTS=1 to start. Restrict access to the env file.

docker run -d --name vibebattle --restart unless-stopped --init \
  --read-only --cap-drop ALL --security-opt no-new-privileges \
  -p 127.0.0.1:4007:4007 --env-file /etc/vibebattle/runner.env \
  "${VIBE_IMAGE:?set VIBE_IMAGE to a pinned GHCR image}"
curl --fail --retry 5 --retry-connrefused http://127.0.0.1:4007/health

Set VIBE_RUNNER_URL in Codebattle to the runner's reachable internal URL and use the same VIBE_RUNNER_TOKEN. For Kubernetes, inject the token through a Secret, put replicas behind an internal Service, and use GET /health for readiness. Run as non-root with a read-only root filesystem and size CPU and memory for four bots per match slot plus the runner.

License

GNU Affero General Public License v3.0. See LICENSE.

About

Rust referee and sandbox supervisor for Codebattle Vibe Tournaments

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages