common/templates/task.memcached

54 lines
1.2 KiB
HCL

[[- /* vim: syntax=hcl
This is a generic, small and reusable memcached task */ -]]
# Local memcached instance
task "memcached" {
driver = "docker"
user = 11211
# Reduce Docker logs collection (huge) overhead
logs {
disabled = true
}
lifecycle {
hook = "prestart"
sidecar = true
}
config {
image = "memcached:alpine"
readonly_rootfs = true
force_pull = true
entrypoint = ["/local/memcached"]
}
template {
data =<<_EOT
#!/bin/sh
set -eu
exec memcached -l 127.0.0.1 -p 11211 -m {{ env "NOMAD_MEMORY_LIMIT" | parseInt | subtract 5 }}
_EOT
destination = "local/memcached"
perms = 755
}
resources {
[[- if and (has . "resources") (has .resources "cpu") ]]
cpu = [[ .resources.cpu ]]
[[- else ]]
cpu = 10
[[- end ]]
[[- if and (has . "resources") (has .resources "memory") ]]
memory = [[ .resources.memory ]]
[[- else ]]
memory = 20
[[- end ]]
[[- if and (has . "resources") (has .resources "memory_max") ]]
memory_max = [[ .resources.memory_max ]]
[[- end ]]
}
}