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.)
- 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.
-
Configure GitHub SSH access (once)
- See docs/setup/github-deploy-key.md
- This ensures your VM can clone your repository.
-
Running Server
- See Step-by-Step Setup below.
-
Runtime Debugging
- See docs/usage/troubleshooting.md
- Some basic commands you can run to debug install and runtime issues.
git clone [email protected]:<YOUR_USER>/<YOUR_FORK>.gitEnsure you are authenticated as a project owner:
gcloud auth application-default login
gcloud config set project <YOUR_PROJECT>Boostrap Service Account:
make bootstrap- See
docs/setup/gcp-service-account.mdfor details.
make build- Installs dependencies and enables services that run on boot.
- (see
scripts/dependenciesandscripts/services) - Steam, Wine, Xvfb, and their dependencies
- Some helpful server side command line tools. e.g., curl, wget, etc.
- Install GCP monitoring packages.
- (see
- (Note that this builds images for all games. See Makefile
helpfor more fine-grained control.)
make terraform-apply-<game>- Replace
<game>withvrisingorbarotrauma. - 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.
- To grant others the ability to start server, see
make destroy- Lowest GCP cost.
make help| 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 |
-
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
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]].