Files
mmd/mmd.nomad
Henrik Jess Nielsen 0d57c9eee5
All checks were successful
Build and Deploy MoneyMaker / build-and-deploy (push) Successful in 15m28s
fix: switch to Consul KV template for secrets injection
- Consul now running on int node (joined cluster)
- provider=consul re-enabled (int has consul.version=1.22.7)
- Removed sed placeholder approach + Gitea secrets requirement
- Added template{} stanzas reading from consul kv mmd/* keys
- Cleaned up deploy.yml (removed sed substitution step)
2026-05-27 15:16:00 +02:00

153 lines
3.4 KiB
HCL

job "moneymaker" {
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
network {
port "http" {}
}
reschedule {
attempts = 5
interval = "10m"
delay = "30s"
delay_function = "exponential"
max_delay = "120s"
unlimited = false
}
constraint {
attribute = "${node.unique.name}"
value = "int"
}
service {
provider = "consul"
name = "moneymaker"
port = "http"
tags = [
"traefik.enable=true",
"traefik.http.routers.moneymaker.rule=Host(`mmd.i80.dk`)",
"traefik.http.routers.moneymaker.tls=true",
]
check {
name = "http_health_check"
type = "http"
path = "/health"
interval = "10s"
timeout = "5s"
check_restart {
limit = 3
grace = "30s"
}
}
}
# -- Dashboard (Flask web app) ----------------------------------------
task "web" {
driver = "docker"
config {
image = "registry.i80.dk/gitea/mmd:latest"
ports = ["http"]
force_pull = true
volumes = ["/opt/nomad/volumes/moneymaker-data:/app/data"]
}
restart {
attempts = 10
interval = "10m"
delay = "10s"
mode = "fail"
}
template {
data = <<EOH
DATABASE_URL="{{ key "mmd/DATABASE_URL" }}"
ANTHROPIC_API_KEY="{{ key "mmd/anthropic_api_key" }}"
SAXO_APP_KEY="{{ key "mmd/SAXO_APP_KEY" }}"
SAXO_APP_SECRET_1="{{ key "mmd/SAXO_APP_SECRET_1" }}"
SAXO_BASE="{{ key "mmd/SAXO_BASE" }}"
HARBOR_ROBOT_TOKEN="{{ key "harbor/robot/token" }}"
EOH
destination = "secrets/app.env"
env = true
}
env {
APP_ENV = "production"
PORT = "${NOMAD_PORT_http}"
HOST = "0.0.0.0"
LOG_DIR = "/app/data/logs"
SAXO_TOKEN_FILE = "/app/data/.saxo_token.json"
HF_HOME = "/app/data/hf-cache"
}
resources {
cpu = 300
memory = 512
}
}
# -- Worker (pipeline scheduler, runs FinBERT + Claude) ----------------
task "worker" {
driver = "docker"
config {
image = "registry.i80.dk/gitea/mmd:latest"
command = "python"
args = ["scheduler.py"]
force_pull = true
volumes = ["/opt/nomad/volumes/moneymaker-data:/app/data"]
}
restart {
attempts = 10
interval = "10m"
delay = "10s"
mode = "fail"
}
template {
data = <<EOH
DATABASE_URL="{{ key "mmd/DATABASE_URL" }}"
ANTHROPIC_API_KEY="{{ key "mmd/anthropic_api_key" }}"
SAXO_APP_KEY="{{ key "mmd/SAXO_APP_KEY" }}"
SAXO_APP_SECRET_1="{{ key "mmd/SAXO_APP_SECRET_1" }}"
SAXO_BASE="{{ key "mmd/SAXO_BASE" }}"
EOH
destination = "secrets/worker.env"
env = true
}
env {
LOG_DIR = "/app/data/logs"
SAXO_TOKEN_FILE = "/app/data/.saxo_token.json"
HF_HOME = "/app/data/hf-cache"
}
resources {
cpu = 1500
memory = 3072
}
}
}
}