129 lines
2.4 KiB
HCL
129 lines
2.4 KiB
HCL
job "builder" {
|
|
namespace = "ci"
|
|
type = "batch"
|
|
|
|
datacenters = ["bespin", "corrin"]
|
|
priority = 100
|
|
|
|
parameterized {
|
|
payload = "optional"
|
|
meta_required = [ "REPO_URL", "COMMIT", "BRANCH", "FLAVOR" ]
|
|
}
|
|
|
|
reschedule {
|
|
attempts = 0
|
|
unlimited = false
|
|
}
|
|
|
|
constraint {
|
|
distinct_hosts = true
|
|
}
|
|
|
|
group "runner" {
|
|
task "warmup-cache" {
|
|
driver = "docker"
|
|
config {
|
|
image = "nixpkgs/nix:nixos-22.11"
|
|
args = [ "/tmp/warmup.sh" ]
|
|
volumes = [
|
|
"local/warmup.sh:/tmp/warmup.sh",
|
|
"/var/cache/albatros/nix:/mnt/nix"
|
|
]
|
|
}
|
|
|
|
lifecycle {
|
|
hook = "prestart"
|
|
sidecar = false
|
|
}
|
|
|
|
template {
|
|
data = file("./warmup.sh")
|
|
destination = "local/warmup.sh"
|
|
perms = "555"
|
|
}
|
|
}
|
|
|
|
task "executor" {
|
|
driver = "docker"
|
|
leader = true
|
|
config {
|
|
image = "nixpkgs/nix:nixos-22.11"
|
|
args = [ "/tmp/builder.sh" ]
|
|
volumes = [
|
|
"local/builder.sh:/tmp/builder.sh",
|
|
"local/nix.conf:/etc/nix/nix.conf",
|
|
"local/secrets:/var/run/secrets/albatros",
|
|
"/var/cache/albatros/nix:/nix:ro",
|
|
"/var/cache/albatros/cacheroot:/mnt/cacheroot"
|
|
]
|
|
}
|
|
|
|
dispatch_payload {
|
|
file = "secrets/secret.txt"
|
|
}
|
|
|
|
env {
|
|
COMMIT = "${NOMAD_META_COMMIT}"
|
|
BRANCH = "${NOMAD_META_BRANCH}"
|
|
REPO_URL = "${NOMAD_META_REPO_URL}"
|
|
FLAVOR = "${NOMAD_META_FLAVOR}"
|
|
GCROOT = "/mnt/cacheroot/${NOMAD_META_COMMIT}"
|
|
NIX_REMOTE = "daemon"
|
|
}
|
|
|
|
template {
|
|
data = file("./user.sh")
|
|
destination = "local/builder.sh"
|
|
perms = "555"
|
|
}
|
|
|
|
template {
|
|
data = file("./nix.conf")
|
|
destination = "local/nix.conf"
|
|
}
|
|
|
|
restart {
|
|
attempts = 0
|
|
}
|
|
|
|
resources {
|
|
# actual work should be done in the nix daemon
|
|
cpu = 100
|
|
memory = 500
|
|
}
|
|
}
|
|
|
|
task "daemon" {
|
|
driver = "docker"
|
|
config {
|
|
image = "nixpkgs/nix:nixos-22.11"
|
|
command = "nix-daemon"
|
|
volumes = [
|
|
"/var/cache/albatros/nix:/nix",
|
|
"local/pin.sh:/usr/local/bin/pin.sh"
|
|
]
|
|
}
|
|
|
|
template {
|
|
data = file("./nix.conf")
|
|
destination = "local/nix.conf"
|
|
}
|
|
|
|
template {
|
|
data = file("./pin.sh")
|
|
destination = "local/pin.sh"
|
|
perms = "555"
|
|
}
|
|
|
|
restart {
|
|
attempts = 0
|
|
}
|
|
|
|
resources {
|
|
cpu = 1000
|
|
memory = 4000
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|