Bot Changes in 2.7 - Running Bots with Docker
-
Bots can now be run with docker. After installing docker on your system, you can run a bot with:
docker run \ --rm \ --network host \ --pull always \ --restart always \ --env BOT_PORT_NUMBER=4000 \ --env LOBBY_URI=https://prod.triplea-game.org \ --env BOT_NAME=BotYOUR_BOT_NAME_HERE \ --env EXIT_ON_GAME_END=true \ --env BOT_MAX_MEMORY=256m \ -v /opt/bot/maps:/downloadedMaps \ -v /home/bot/triplea/savedGames/autoSave:/home/bot/triplea/savedGames/autoSave \ --name bot \ ghcr.io/triplea-game/bot:latest
The above mounts two folders, these folders need to exist on your file system:
/opt/bot/maps
/home/bot/triplea/savedGames/autoSave
Those folders need to be owned by a user named 'bot' with UID '999'
Port 4000 needs to be opened up on firewall.
To download maps, this is a download script: https://github.com/triplea-game/infrastructure/blob/master/ansible/roles/bot/templates/download-all-maps.sh.j2
You'll need to download that, modify it as needed, replace anything that is in double braces, eg:
{{ ... }}
.Then
chmod +x <script>
and then run it. Put the script on a cronjob and maps will be updated regularly.Note the "--pull always", which means the latest version of the bots will be started each time on startup. Also note the "exit on game end" flag, which restarts when a game ends. This way, after each game - the bot will shutdown. Note the "--restart always" which will have docker automatically start the bot whenever it is shut down. Thereby, the bot will restart between games & will then automatically update and read any updated maps on the file system.
More info & authoritative documentation for everything bots, is at: https://github.com/triplea-game/triplea/tree/master/game-app/game-headless
-
The 'EXIT_ON_GAME_END' flag is new in 2.7.
All 2.7 lobby bots have this configured.
The lobby bots are configured in a very similar way, except as a linux service (using systemctl)The way lobby bots are installed can be reverse engineered from: