diff --git a/images/papermc/Containerfile b/images/papermc/Containerfile index 7958d1b..402973c 100644 --- a/images/papermc/Containerfile +++ b/images/papermc/Containerfile @@ -13,6 +13,12 @@ RUN curl -s "https://fill.papermc.io/v3/projects/paper/versions/$MINECRAFT_VERSI | jq -r '.downloads."server:default".url' \ | xargs curl -o server.jar +RUN wget -P /data/plugins \ + https://git.lab0x13.site/api/packages/scrow/generic/core-bukkit/UNVERSIONED/CoreBukkit.jar \ + https://download.luckperms.net/1652/bukkit/loader/LuckPerms-Bukkit-5.5.65.jar \ + https://hangarcdn.papermc.io/plugins/ViaVersion/ViaVersion/versions/5.11.0/PAPER/ViaVersion-5.11.0.jar \ + https://hangarcdn.papermc.io/plugins/ViaVersion/ViaBackwards/versions/5.11.0/PAPER/ViaBackwards-5.11.0.jar + RUN printf eula=true > eula.txt RUN java -jar server.jar --initSettings diff --git a/images/papermc/plugins/LuckPerms-Bukkit-5.5.65.jar b/images/papermc/plugins/LuckPerms-Bukkit-5.5.65.jar deleted file mode 100644 index c13db8f..0000000 Binary files a/images/papermc/plugins/LuckPerms-Bukkit-5.5.65.jar and /dev/null differ diff --git a/images/papermc/plugins/ViaBackwards-5.11.0.jar b/images/papermc/plugins/ViaBackwards-5.11.0.jar deleted file mode 100644 index 9b1858f..0000000 Binary files a/images/papermc/plugins/ViaBackwards-5.11.0.jar and /dev/null differ diff --git a/images/papermc/plugins/ViaVersion-5.11.0.jar b/images/papermc/plugins/ViaVersion-5.11.0.jar deleted file mode 100644 index 1f3116d..0000000 Binary files a/images/papermc/plugins/ViaVersion-5.11.0.jar and /dev/null differ diff --git a/jobs/README.minecraft.md b/jobs/README.minecraft.md new file mode 100644 index 0000000..d53e92b --- /dev/null +++ b/jobs/README.minecraft.md @@ -0,0 +1,11 @@ +we reuse the same minecraft job/service for all gamemodes and the lobby. +the following variables are supported: +- mode(, required): name of the gamemode to run. this is used to advertise. +- image(, required): image to use, something based on papermc normally. +- plugins(, 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. diff --git a/jobs/lobby.nomad.hcl b/jobs/minecraft.nomad.hcl similarity index 50% rename from jobs/lobby.nomad.hcl rename to jobs/minecraft.nomad.hcl index 4caf36c..951d803 100644 --- a/jobs/lobby.nomad.hcl +++ b/jobs/minecraft.nomad.hcl @@ -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 { diff --git a/minigame/lobby.varfile.hcl b/minigame/lobby.varfile.hcl new file mode 100644 index 0000000..00aaded --- /dev/null +++ b/minigame/lobby.varfile.hcl @@ -0,0 +1,5 @@ +mode = "lobby" +image = "git.lab0x13.site/scrow/papermc:0.2" +plugins = [ + "https://git.lab0x13.site/api/packages/scrow/generic/core-bukkit/UNVERSIONED/CoreBukkit.jar", +] diff --git a/minigame/run b/minigame/run new file mode 100755 index 0000000..c9a0d85 --- /dev/null +++ b/minigame/run @@ -0,0 +1,9 @@ +#!/bin/sh +set -eu +varfile="${1:-}" +test -n "$varfile" || { + printf 'usage: %s VARFILE\n' "$0" + exit 1 +} + +nomad job run -var-file "$varfile" ../jobs/minecraft.nomad.hcl