This commit is contained in:
kento2 2026-08-19 19:12:32 +02:00
parent 8f29a4f56d
commit b7623bab85
8 changed files with 60 additions and 32 deletions

11
jobs/README.minecraft.md Normal file
View file

@ -0,0 +1,11 @@
we reuse the same minecraft job/service for all gamemodes and the lobby.
the following variables are supported:
- mode(<string>, required): name of the gamemode to run. this is used to advertise.
- image(<string>, required): image to use, something based on papermc normally.
- plugins(<list(string)>, optional): space-separated list of URLs to download to the plugins folder.
We use images to make gamemode specific changes cause else we'd need a lot of
variables and it'd just become a mess. we still need the plugins variable cause
we don't want to rebuild our images every time we release a new update.
our plugins also are usually unversioned, so we'd break reproducability if we'd
fetch them in the images directly.

View file

@ -1,4 +1,20 @@
job "lobby" {
variable "mode" {
type = string
description = "gamemode to advertise as; e.g. lobby or bedwars"
}
variable "image" {
type = string
description = "docker image to use"
}
variable "plugins" {
type = list(string)
description = "list of URLs to download to the plugins directory"
default = []
}
job "minecraft" {
type = "service"
group "lobby" {
@ -15,10 +31,10 @@ job "lobby" {
}
service {
name = "lobby"
name = var.mode
port = "minecraft"
address_mode = "alloc"
tags = ["minecraft"]
tags = ["minecraft", var.mode]
check {
type = "tcp"
interval = "5s"
@ -26,41 +42,22 @@ job "lobby" {
}
}
ephemeral_disk {
size = 5000 # 5 gb
}
task "download-plugins" {
driver = "docker"
lifecycle {
hook = "prestart"
sidecar = false
}
config {
image = "busybox"
command = "sh"
volumes = ["../alloc/data:/mnt"]
args = [
"-xec",
<<-EOF
mkdir -p /mnt/plugins
wget -P /mnt/plugins \
https://git.lab0x13.site/api/packages/scrow/generic/core-bukkit/UNVERSIONED/CoreBukkit.jar
EOF
]
}
}
task "run" {
driver = "docker"
dynamic "artifact" {
for_each = var.plugins
content {
source = artifact.value
destination = "local/plugins"
}
}
config {
image = "git.lab0x13.site/scrow/papermc:0.2"
image = var.image
force_pull = false
ports = ["minecraft"]
volumes = ["../alloc/data:/mnt"]
volumes = ["local:/mnt"]
}
env {