Skip to content

bwinter/baroboys

Repository files navigation

Infrastructure Automation for Game Servers

This project automates the hosting of game servers (currently works for VRising and Barotrauma).

A design priority was low cost, ideally 0 when unused. To that end, this repo saves all state (essentially) to GitHub - allowing terraform destory to purge GCP down to a near 0 cost.

(I would love to have demoed k8s and Go in this project, but I think they would be unnecessary complexities for a relatively simple project.)

Tech Stack tl;dr is: GCP, Packer, Terraform, and Bash. (+ Steam, and a few linux tools)

There is a small admin console for managing the server and accessing the logs as well. It was designed to give limited admin control and debugging details without needing technical skills. (It doesn't currently separate game UI well – aka it needs some work but is functional.)


🧰 Requirements

  • Terraform
    brew tap hashicorp/tap
    brew install hashicorp/tap/terraform
  • Packer
    brew tap hashicorp/tap
    brew install hashicorp/tap/packer
  • Google Cloud SDK (gcloud) (see docs/setup/installing-gcloud.md for help installing)
  • A valid GCP project (e.g., europan-world)
  • GitHub project (e.g. baroboys)
  • direnv (see .envrc for configuration)
    • TODO: need to make a boostrap for this / centralize configuration.

🚀 Getting Started

  1. Configure GitHub SSH access (once)

  2. Running Server

  3. Runtime Debugging


🚀 Step-by-Step Setup

1. Fork this repo and then clone it

git clone [email protected]:<YOUR_USER>/<YOUR_FORK>.git

2. Create Service Accounts and Terraform Buckets

Ensure you are authenticated as a project owner:

gcloud auth application-default login
gcloud config set project <YOUR_PROJECT>

Boostrap Service Account:

make bootstrap

3. Build all packer images

make build
  • Installs dependencies and enables services that run on boot.
    • (see scripts/dependencies and scripts/services)
    • Steam, Wine, Xvfb, and their dependencies
    • Some helpful server side command line tools. e.g., curl, wget, etc.
    • Install GCP monitoring packages.
  • (Note that this builds images for all games. See Makefile help for more fine-grained control.)

4. Apply Terraform to create the VM and start the game server

make terraform-apply-<game>
  • Replace <game> with vrising or barotrauma.
  • This boots game VM
  • Note the server shuts down after 30 minutes of inactivity. Saving the game at the same time.
  • To restart the server, simply power it back on via the GCP UI.
    • To grant others the ability to start server, see make iam-add-admin.

5. (Optional) Destroy the instance when done with the server

make destroy
  • Lowest GCP cost.

6. See Makefile help for more options

make help

🛠️ Debugging

Goal Command
View startup logs gcloud compute instances get-serial-port-output europa --zone=us-west1-c
View systemd logs journalctl -u google-startup-scripts.service -e

📦 Repo Structure

  • General Documentation (/docs)

    • Setup and usage instructions
  • Bootstrapping (/bootstrap)

    • Sets up service accounts and TF buckets.
  • VM Image (/packer)

    • Installs dependencies and enables services that run on boot.
  • Infrastructure (/terraform)

    • Provisions VMs, setup firewall rules, etc.
  • Gameserver Setup and Execution (/scripts)

    • Installers / updaters for environment dependencies
    • Services that support the game's server
    • Misc tools for debugging and development
    • (Note: This section is a work in progress and may evolve as the project matures.)
      • It works fairly well, but it's possible there might be a better separation of concerns.
  • Barotrauma State & Mods (/Barotrauma)

    • Contains saved games, mod files, and game server config
  • VRising State & Mods (/VRising)

    • Contains saved games and game server config

License

This project is licensed under the Polyform Small Business License.

  • ✅ Free for personal, educational use
  • ❌ Commercial use by larger companies requires a commercial license

If you’re a business that would like to use this project, please contact me at [[email protected]].

About

Headless Game Server (GCP, Terraform, and more)

Topics

Resources

License

Stars

Watchers

Forks

Contributors 2

  •  
  •