.
This commit is contained in:
parent
b7623bab85
commit
d6e4cae9c6
60 changed files with 486 additions and 93 deletions
|
|
@ -1,21 +1,14 @@
|
|||
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"
|
||||
type = "batch"
|
||||
|
||||
parameterized {
|
||||
meta_required = ["mode", "image"]
|
||||
meta_optional = ["plugins"]
|
||||
}
|
||||
|
||||
meta {
|
||||
plugins = ""
|
||||
}
|
||||
|
||||
group "lobby" {
|
||||
count = 1
|
||||
|
|
@ -31,10 +24,12 @@ job "minecraft" {
|
|||
}
|
||||
|
||||
service {
|
||||
name = var.mode
|
||||
name = "minecraft"
|
||||
port = "minecraft"
|
||||
address_mode = "alloc"
|
||||
tags = ["minecraft", var.mode]
|
||||
meta {
|
||||
mode = "${NOMAD_META_MODE}"
|
||||
}
|
||||
check {
|
||||
type = "tcp"
|
||||
interval = "5s"
|
||||
|
|
@ -42,22 +37,37 @@ job "minecraft" {
|
|||
}
|
||||
}
|
||||
|
||||
task "run" {
|
||||
task "download-plugins" {
|
||||
driver = "docker"
|
||||
|
||||
dynamic "artifact" {
|
||||
for_each = var.plugins
|
||||
content {
|
||||
source = artifact.value
|
||||
destination = "local/plugins"
|
||||
}
|
||||
lifecycle {
|
||||
hook = "prestart"
|
||||
sidecar = false
|
||||
}
|
||||
|
||||
config {
|
||||
image = var.image
|
||||
force_pull = false
|
||||
image = "busybox"
|
||||
command = "sh"
|
||||
volumes = ["../alloc/data:/mnt"]
|
||||
args = [
|
||||
"-cxe",
|
||||
<<-EOF
|
||||
set -eu
|
||||
mkdir /mnt/plugins
|
||||
wget -P /mnt/plugins ${NOMAD_META_PLUGINS}
|
||||
EOF
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
task "run" {
|
||||
driver = "docker"
|
||||
|
||||
config {
|
||||
image = "${NOMAD_META_IMAGE}"
|
||||
force_pull = true
|
||||
ports = ["minecraft"]
|
||||
volumes = ["local:/mnt"]
|
||||
volumes = ["../alloc/data:/mnt"]
|
||||
}
|
||||
|
||||
env {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue