-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
services/nomad/build: add buildbot worker nomad jobs
- Loading branch information
1 parent
6fbfdca
commit e12ec4a
Showing
1 changed file
with
127 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
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 { | ||
// TODO: proper image name and version (same as main container) | ||
image = "localhost:5000/infra-buildbot-builder: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 { | ||
// TODO: proper image name and version | ||
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 = "Void Linux Buildbot builder for ${group.value.name} running on ${attr.unique.hostname}" | ||
destination = "local/info/host" | ||
} | ||
|
||
template { | ||
data = <<EOF | ||
{{- with nomadVar 'nomad/jobs/buildbot-worker' -}} | ||
{{ .worker_password }} | ||
{{- end -}} | ||
EOF | ||
destination = "local/secrets/worker-password" | ||
perms = "400" | ||
// TODO: proper uid:gid? | ||
uid = 5000 | ||
gid = 5000 | ||
} | ||
} | ||
} | ||
} | ||
} |