Running your own Factorio server on Google Cloud
Much like the game itself, this project aims to automate as much as possible, when it comes to running your own Factorio server.
The scripts are based around the use of preemptible VMs which keeps running costs low.
- Make sure the following tools are installed, available in your
$PATH
, and (where necessary) authorised: - Get started on the GCP Free Tier and create a new Google Cloud project
- Note: you are responsible for the running costs incurred by this project beyond the limits of the Free Tier. Every effort has been made to optimise and minimise the costs of resource usage, and as of this writing running a server for ~50 hours a month cost less than £5 in total, but this is an isolated example from a sample size of 1.
- Set the
CLOUDSDK_CORE_PROJECT
environment variable to the Google Cloud project ID- For example:
export CLOUDSDK_CORE_PROJECT=my-factorio-server-kit
- For example:
- Run up the Terraform stack to provision infrastructure in GCP (implemented? -> ❌/✅)
- Cloud Pub/Sub topic
cleanup-instances
✅ - Cloud Scheduler job
cleanup-instances
to publish to topic ✅ - Cloud Function
cleanup-instances
to clean up terminated instances, triggered by topic ✅ - Cloud Storage buckets
<project>-backup-saves
❌<project>-saves-<location>
✅<project>-storage
❌
- Cloud DNS (optional)
- Managed zone ❌
- Record set ❌
- Cloud Pub/Sub topic
- Run the Cloud Build pipelines in order
- Fire off the
roll-vm.sh
Bash script described below
The project is primarily driven by Bash scripts, supported by Cloud Build pipelines and Terraform infrastructure-as-code.
- roll-vm.sh - the main point of execution; will run up a GCE VM hosting Docker containers for
the Factorio server itself, as well as additional containers with Grafana and Prometheus that tie into Graftorio
- the location/region that the VM will deploy to follows a default based on the
locations.json
file, and can be overridden with a--<location>
flag; seeroll-vm.sh --help
for more information - the machine type of the VM can be specified with the
--machine-type=...
flag
- the location/region that the VM will deploy to follows a default based on the
- delete-vm.sh - deletes any VMs currently running in the project, optionally filtering by name
Each of the above scripts taps into a common library of functionality under the lib directory.
The two settings files map-settings.json
and map-gen-settings.json
can be created from a map exchange string in the
game as outlined here.
goppuku
is a small Go binary/service I built to have a server shut itself down if the player count stays at zero
for fifteen consecutive minutes.
The latest release of goppuku
is installed in the Factorio server image by Packer's provisioner script.
👤 James Lucktaylor
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update documentation and tests as appropriate.
Give a ⭐️ if this project helped you!
Copyright © 2020 James Lucktaylor.
This project is licensed with the Unlicense.
This README was generated with ❤️ by readme-md-generator