Skip to content

Commit

Permalink
services/nomad/build: add buildbot worker nomad jobs
Browse files Browse the repository at this point in the history
  • Loading branch information
classabbyamp committed Jul 6, 2024
1 parent 2c8066f commit 88a7474
Showing 1 changed file with 125 additions and 0 deletions.
125 changes: 125 additions & 0 deletions services/nomad/build/buildbot-builder.nomad
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
job "buildbot-builder" {
type = "service"
// TODO
// datacenters = ["VOID"]
// namespace = "build"
datacenters = ["dc1"]

dynamic "group" {
for_each = [
// TODO: jobs = 16, 6, 3
// TODO: mem = ?, ?, ?
{ name = "glibc", jobs = 2, mem = 8192 },
{ name = "musl", jobs = 2, mem = 8192 },
{ name = "aarch64", jobs = 2, mem = 8192 },
]
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:latest"
command = "sh"
args = ["-c", "chown -R 5000:5000 /hostdir"]
}

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

lifecycle {
hook = "prestart"
}
}

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

user = "void-builder"

config {
image = "localhost:5000/infra-buildbot-builder:latest"
force_pull = true
cap_add = ["sys_admin"]
}

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

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 = "${group.value.name} builder"
destination = "local/info/host"
}

template {
data = <<EOF
{{- with nomadVar 'nomad/jobs/buildbot-worker' -}}
{{ .${group.value.name}_password }}
{{- end -}}
EOF
destination = "local/secrets/worker-password"
perms = "400"
// TODO: proper uid:gid?
uid = 5000
gid = 5000
}
}
}
}
}

0 comments on commit 88a7474

Please sign in to comment.