Skip to content

Building from source

Pavel Erokhin edited this page Oct 19, 2026 · 1 revision

The exporter is a single Go program. You need Go 1.27 (the toolchain line in go.mod names the exact version) and, for the image, Docker.

Build the binary

  1. Clone the repository:

    git clone https://github.com/MairwunNx/minecraft-exporter.git
    cd minecraft-exporter
  2. Run the tests: go test ./.... They use a fake WorldAPI and never touch the network.

  3. Build: go build .. The binary reports its version as dev.

To stamp a version and build for another system, as the release does:

CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -trimpath -ldflags "-s -w -X main.version=1.2.3" -o minecraft-exporter .

Build the image

docker build --build-arg VERSION=1.2.3 -t minecraft-exporter:test .

The Dockerfile compiles on the build machine's own architecture and cross-compiles for the target, so a multi-arch build (docker buildx build --platform linux/amd64,linux/arm64 .) needs no emulation. The final image is gcr.io/distroless/static-debian13:nonroot: the binary alone, run as a non-root user, listening on 10059.

Try it against a real server

WORLDAPI_URL=http://localhost:8110/api/v1 EXPORTER_LISTEN=127.0.0.1:10059 go run .
curl -s 127.0.0.1:10059/metrics | grep '^minecraft_'

To see the dashboard with your build, tag the image minecraft-exporter:test, change the exporter's image: in examples/compose.yaml to it, and start the stack as Installation shows.

Next: Architecture.

Clone this wiki locally