114 lines
2.7 KiB
HCL
114 lines
2.7 KiB
HCL
job "homeassistant" {
|
|
datacenters = ["dc1"]
|
|
type = "service"
|
|
|
|
constraint {
|
|
attribute = "${attr.kernel.name}"
|
|
value = "linux"
|
|
}
|
|
|
|
constraint {
|
|
attribute = "${attr.unique.hostname}"
|
|
operator = "regexp"
|
|
value = "odroid.*"
|
|
}
|
|
|
|
group "hass" {
|
|
count = 1
|
|
|
|
restart {
|
|
attempts = 99
|
|
interval = "1h"
|
|
delay = "10s"
|
|
mode = "delay"
|
|
}
|
|
|
|
task "wait-for-postgres" {
|
|
driver = "docker"
|
|
lifecycle {
|
|
hook = "prestart"
|
|
sidecar = false
|
|
}
|
|
config {
|
|
image = "postgres:16-alpine"
|
|
command = "sh"
|
|
args = ["-c", "until pg_isready -h master.postgres.service.dc1.consul -U hass; do sleep 3; done"]
|
|
}
|
|
resources {
|
|
cpu = 50
|
|
memory = 64
|
|
}
|
|
}
|
|
|
|
task "config-backup" {
|
|
driver = "docker"
|
|
lifecycle {
|
|
hook = "poststart"
|
|
sidecar = true
|
|
}
|
|
config {
|
|
image = "alpine:3.19"
|
|
command = "sh"
|
|
args = ["-c", "apk add --no-cache rsync && while true; do rsync -a --delete --exclude='*.db*' --exclude='*.log*' --exclude='tts/' --exclude='deps/' --exclude='__pycache__/' /config/ /configbackup/; sleep 1800; done"]
|
|
volumes = [
|
|
"/mnt/Public/config/homeassistant:/config:ro",
|
|
"/mnt/Public/config/homeassistant-backup:/configbackup",
|
|
]
|
|
}
|
|
resources {
|
|
cpu = 30
|
|
memory = 64
|
|
}
|
|
}
|
|
|
|
task "hass" {
|
|
driver = "docker"
|
|
config {
|
|
image = "ghcr.io/home-assistant/home-assistant:stable"
|
|
image_pull_timeout = "10m"
|
|
force_pull = false
|
|
network_mode = "host"
|
|
cap_add = ["NET_ADMIN"]
|
|
volumes = [
|
|
"/etc/localtime:/etc/localtime:ro",
|
|
"/mnt/Public/config/homeassistant:/config",
|
|
]
|
|
}
|
|
|
|
env {
|
|
JEMALLOC_DISABLE = true
|
|
PUID = "1000"
|
|
PGID = "0"
|
|
SKIP_CHOWN = "true"
|
|
}
|
|
|
|
resources {
|
|
cpu = 256
|
|
memory = 512
|
|
}
|
|
|
|
service {
|
|
name = "homeassistant"
|
|
tags = ["global", "homeassistant", "migration-target", "logo=home-assistant"]
|
|
port = "http"
|
|
|
|
check {
|
|
type = "http"
|
|
path = "/api/config"
|
|
interval = "10s"
|
|
timeout = "2s"
|
|
header {
|
|
Authorization = ["Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiI3MGI3ZmQzN2RhNjg0ZDcwYmI0MzhlYjJhNzc1NTNjMSIsImlhdCI6MTc3ODQ1Njc1MiwiZXhwIjoyMDkzODE2NzUyfQ.gAWoByWWDDW9YSUpTZHb-xtdiFo-0u5RqHsxKhMQ4rc"]
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
network {
|
|
port "http" {
|
|
static = 8123
|
|
}
|
|
}
|
|
}
|
|
}
|