Skip to content

Commit

Permalink
services/nomad/build: add buildbot worker nomad job
Browse files Browse the repository at this point in the history
  • Loading branch information
classabbyamp committed Sep 28, 2024
1 parent ab0882e commit 223eb43
Showing 1 changed file with 135 additions and 0 deletions.
135 changes: 135 additions & 0 deletions services/nomad/build/buildbot-builder.nomad
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
job "buildbot-builder" {
type = "service"
datacenters = ["VOID"]
namespace = "build"

dynamic "group" {
for_each = [
// memory is ~85% of capacity
{ name = "glibc", jobs = 16, mem = 109512 },
{ name = "musl", jobs = 6, mem = 54512 },
{ name = "aarch64", jobs = 3, mem = 27256 },
]
labels = [ "buildbot-builder-${group.value.name}" ]

content {
dynamic "volume" {
for_each = [ "${group.value.name}" ]
labels = [ "${volume.value}_hostdir" ]

content {
type = "host"
source = "${volume.value}_hostdir"
read_only = false
}
}

// https://github.com/hashicorp/nomad/issues/8892
task "prep-hostdir" {
driver = "docker"

config {
image = "ghcr.io/void-linux/void-glibc-full:20240526R1"
command = "chown"
args = ["-R", "418:418", "/hostdir"]
}

volume_mount {
volume = "${group.value.name}_hostdir"
destination = "/hostdir"
}

lifecycle {
hook = "prestart"
}
}

task "buildbot-worker" {
driver = "docker"

user = "void-builder"

config {
image = "ghcr.io/void-linux/infra-buildbot-builder:20240928R1"
force_pull = true
cap_add = ["sys_admin"]
}

resources {
cores = "${group.value.jobs}"
memory = "${group.value.mem}"
}

volume_mount {
volume = "${group.value.name}_hostdir"
destination = "/hostdir"
}

template {
data = <<EOF
{{ $allocID := env "NOMAD_ALLOC_ID" -}}
{{ range nomadService 1 $allocID "buildbot-worker" -}}
[buildbot]
host = {{ .Address }}
worker-port = {{ .Port }}
{{ end -}}
[worker]
name = worker-${group.value.name}
EOF
destination = "local/config.ini"
}

template {
data = <<EOF
XBPS_MAKEJOBS=${group.value.jobs}
XBPS_CHROOT_CMD=uchroot
XBPS_CHROOT_CMD_ARGS='-t'
XBPS_CCACHE=yes
XBPS_DEBUG_PKGS=yes
XBPS_USE_GIT_REVS=yes
XBPS_DISTFILES_MIRROR=https://sources.voidlinux.org
XBPS_PRESERVE_PKGS=yes
EOF
destination = "local/xbps-src.conf"
}

template {
data = "Void Build Operators <[email protected]>"
destination = "local/info/admin"
}

template {
data = <<EOF
Void Linux Buildbot builder for ${group.value.name} running on {{ env "attr.unique.hostname" -}}
EOF
destination = "local/info/host"
}

template {
data = <<EOF
{{- with nomadVar "nomad/jobs/buildbot-worker" -}}
{{ .worker_password }}
{{- end -}}
EOF
destination = "secrets/buildbot/worker-password"
perms = "400"
uid = 418
gid = 418
}

template {
data = <<EOF
{{- with nomadVar "nomad/jobs/buildsync" -}}
{{ .${group.value.name}_password }}
{{- end -}}
EOF
destination = "secrets/rsync/password"
perms = "400"
uid = 418
gid = 418
}
}
}
}
}

0 comments on commit 223eb43

Please sign in to comment.