A robust worker implementation for the Saiblo platform
The easiest way to get started is using our pre-built Docker image:
docker run -dit -e GAME_HOST_IMAGE=<your-game-host-image> -e NAME=<worker-name> --mount type=bind,src=/var/run/docker.sock,dst=/var/run/docker.sock --rm ghcr.io/thuasta/saiblo-worker
Once launched, the worker will establish a connection to the Saiblo server and begin processing matches.
To build the image locally:
docker build -t saiblo-worker .
-
Ensure you have Docker 27.5 and Python 3.13 installed (other versions might work but aren't officially supported)
-
Create a
.env
file with your configuration -
Install required packages:
pip install -r requirements.txt
-
Launch the worker:
python main.py
The following environment variables control the worker's behavior:
-
NAME
: Worker identifier (required) -
AGENT_BUILD_TIMEOUT
: Agent build timeout in seconds (default:300
) -
AGENT_CPUS
: Agent container CPU allocation (default:0.5
) -
AGENT_MEM_LIMIT
: Agent container memory limit (default:1g
) -
GAME_HOST_IMAGE
: Game host container image name (required) -
GAME_HOST_CPUS
: Game host container CPU allocation (default:1
) -
GAME_HOST_MEM_LIMIT
: Game host container memory limit (default:1g
) -
HTTP_BASE_URL
: API endpoint base URL (default:https://api.dev.saiblo.net
) -
WEBSOCKET_URL
: Saiblo WebSocket endpoint (default:wss://api.dev.saiblo.net/ws/
) -
JUDGE_TIMEOUT
: Match duration limit in seconds (default:600
) -
LOGGING_LEVEL
: Logging verbosity level (default:INFO
)
The worker automatically injects these environment variables:
Game host container:
TOKENS
: Comma-separated player tokens
Agent container:
TOKEN
: Player-specific tokenGAME_HOST
: Game host service address
Check out the examples directory for agent and game host image examples.
After each match, the game host container must generate two files:
-
/app/data/result.json
: Match outcome and statisticsExample:
{ "scores": { "token_1": 1.14, "token_2": 5.14 } }
-
/app/data/replay.dat
: Binary replay data
The worker automatically processes these files and reports results to the Saiblo server.
We welcome contributions! Feel free to submit pull requests.
AGPL-3.0-or-later © ASTA