The OAuth token shares one rate budget across everything on the subscription (incl. interactive Claude Code sessions), so citti's translation is almost always throttled while coding — hence the page staying German. Template now emits ANTHROPIC_API_KEY from citti/anthropic_api_key when set (its own rate budget, no contention), else the OAuth token. Only one var is written so an empty key can't shadow the token.
127 lines
2.8 KiB
HCL
127 lines
2.8 KiB
HCL
variable "image_tag" {
|
|
type = string
|
|
default = "latest"
|
|
}
|
|
|
|
job "citti" {
|
|
region = "global"
|
|
datacenters = ["dc1"]
|
|
type = "service"
|
|
|
|
update {
|
|
stagger = "30s"
|
|
max_parallel = 1
|
|
canary = 1
|
|
min_healthy_time = "10s"
|
|
healthy_deadline = "5m"
|
|
auto_revert = true
|
|
auto_promote = true
|
|
progress_deadline = "10m"
|
|
}
|
|
|
|
group "app" {
|
|
count = 1
|
|
|
|
constraint {
|
|
attribute = "${node.unique.name}"
|
|
value = "int"
|
|
}
|
|
|
|
network {
|
|
port "http" {}
|
|
}
|
|
|
|
reschedule {
|
|
attempts = 5
|
|
interval = "10m"
|
|
delay = "30s"
|
|
delay_function = "exponential"
|
|
max_delay = "120s"
|
|
unlimited = false
|
|
}
|
|
|
|
ephemeral_disk {
|
|
size = 500
|
|
sticky = true
|
|
migrate = true
|
|
}
|
|
|
|
service {
|
|
provider = "consul"
|
|
name = "citti"
|
|
port = "http"
|
|
|
|
tags = [
|
|
"traefik.enable=true",
|
|
"traefik.http.routers.citti.rule=Host(`citti.i80.dk`)",
|
|
"traefik.http.routers.citti.tls=true",
|
|
]
|
|
|
|
canary_tags = [
|
|
"traefik.enable=false",
|
|
]
|
|
|
|
check {
|
|
name = "http_health_check"
|
|
type = "http"
|
|
path = "/health"
|
|
interval = "10s"
|
|
timeout = "5s"
|
|
|
|
check_restart {
|
|
limit = 3
|
|
grace = "10s"
|
|
}
|
|
}
|
|
}
|
|
|
|
task "web" {
|
|
driver = "docker"
|
|
|
|
config {
|
|
image = "registry.i80.dk/gitea/citti:${var.image_tag}"
|
|
ports = ["http"]
|
|
force_pull = true
|
|
}
|
|
|
|
restart {
|
|
attempts = 10
|
|
interval = "10m"
|
|
delay = "10s"
|
|
mode = "fail"
|
|
}
|
|
|
|
env {
|
|
DATA_DIR = "${NOMAD_ALLOC_DIR}/data"
|
|
PORT = "${NOMAD_PORT_http}"
|
|
HOST = "0.0.0.0"
|
|
}
|
|
|
|
# Claude credential for DA translation + AI offer matching.
|
|
# Prefer a dedicated API key (citti/anthropic_api_key) — its own rate
|
|
# budget, so citti doesn't compete with interactive Claude Code sessions
|
|
# on the same subscription. Else fall back to the OAuth token, set as
|
|
# ANTHROPIC_AUTH_TOKEN (the app adds the oauth-2025-04-20 beta header).
|
|
# Only ONE var is written: an empty ANTHROPIC_API_KEY would shadow the
|
|
# token, so we never emit it unless the key actually exists. If neither
|
|
# is set the token var is empty and offers stay German (heuristic match).
|
|
template {
|
|
data = <<EOT
|
|
{{ if keyExists "citti/anthropic_api_key" -}}
|
|
ANTHROPIC_API_KEY={{ key "citti/anthropic_api_key" }}
|
|
{{- else -}}
|
|
ANTHROPIC_AUTH_TOKEN={{ keyOrDefault "citti/claude_oauth_token" "" }}
|
|
{{- end }}
|
|
EOT
|
|
destination = "secrets/app.env"
|
|
env = true
|
|
}
|
|
|
|
resources {
|
|
cpu = 200
|
|
memory = 256
|
|
}
|
|
}
|
|
}
|
|
}
|