Refactor Nomad job configuration for nomad-mcp service

This commit is contained in:
2025-02-26 17:25:35 +07:00
parent acae88076c
commit e3e19f5099
2 changed files with 33 additions and 36 deletions

Binary file not shown.

View File

@ -1,5 +1,5 @@
job "nomad-mcp" {
datacenters = ["dc1"]
datacenters = ["jm"]
type = "service"
namespace = "development"
@ -16,52 +16,43 @@ job "nomad-mcp" {
driver = "docker"
config {
image = "python:3.11-slim"
image = "registry.dev.meisheng.group/nomad_mcp:20250226"
ports = ["http"]
command = "python"
args = ["-m", "uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]
}
mount {
type = "bind"
source = "local/nomad_mcp"
target = "/app"
readonly = false
# Pull code from Gitea
artifact {
source = "git::ssh://git@gitea.service.mesh:2222/Mei_Sheng_Textiles/nomad_mcp.git"
destination = "local/nomad_mcp"
options {
ref = "main" # or whichever branch/tag you want to use
sshkey = "LS0tLS1CRUdJTiBPUEVOU1NIIFBSSVZBVEUgS0VZLS0tLS0KYjNCbGJuTnphQzFyWlhrdGRqRUFBQUFBQkc1dmJtVUFBQUFFYm05dVpRQUFBQUFBQUFBQkFBQUFNd0FBQUF0emMyZ3RaVwpReU5UVXhPUUFBQUNBY01oYkNPVXhFOHBYQ3d5UEh0ZFR4aThHU0pzNEdTNXZ6ZTR6Tm1ueUYvUUFBQUtCQm5RZi9RWjBICi93QUFBQXR6YzJndFpXUXlOVFV4T1FBQUFDQWNNaGJDT1V4RThwWEN3eVBIdGRUeGk4R1NKczRHUzV2emU0ek5tbnlGL1EKQUFBRURreWwzQlZlek9YUWZUNzZac0NkYTZPNTFnMExsb25EMEd6L2Y4SHh3dzRCd3lGc0k1VEVUeWxjTERJOGUxMVBHTAp3WkltemdaTG0vTjdqTTJhZklYOUFBQUFHR1JsY0d4dmVTQnJaWGtnWm05eUlHNXZiV0ZrWDIxamNBRUNBd1FGCi0tLS0tRU5EIE9QRU5TU0ggUFJJVkFURSBLRVktLS0tLQo="
}
}
artifact {
source = "git::https://gitea.dev.meisheng.group/nkohl/nomad_mcp.git"
destination = "local/nomad_mcp"
}
env {
# Nomad connection settings
NOMAD_ADDR = "http://pjmldk01.ds.meisheng.group:4646"
NOMAD_NAMESPACE = "development"
LOG_LEVEL = "DEBUG"
PYTHONPATH = "/app"
NOMAD_SKIP_VERIFY = "true"
# API settings
PORT = "8000"
HOST = "0.0.0.0"
# Logging level
LOG_LEVEL = "INFO"
# Enable to make development easier
RELOAD = "true"
# Set PYTHONPATH to include the app directory
PYTHONPATH = "/local/nomad_mcp"
STATIC_DIR = "/local/nomad_mcp/static"
}
# Add a template to create the static directory if it doesn't exist
template {
data = <<EOH
#!/bin/bash
echo "Ensuring static directory exists at ${STATIC_DIR}"
mkdir -p ${STATIC_DIR}
chmod -R 755 ${STATIC_DIR}
echo "Static directory setup complete"
EOH
destination = "local/setup_static.sh"
perms = "755"
}
# Run the setup script before starting the application
lifecycle {
hook = "prestart"
command = "/bin/bash"
args = ["local/setup_static.sh"]
}
resources {
cpu = 200
memory = 256
@ -73,7 +64,8 @@ EOH
tags = [
"traefik.enable=true",
"traefik.http.routers.nomad-mcp.entryPoints=https",
"traefik.http.routers.nomad-mcp.rule=Host(`nomad_mcp.dev.meisheng.group`)"
"traefik.http.routers.nomad-mcp.rule=Host(`nomad_mcp.dev.meisheng.group`)",
"traefik.http.routers.nomad-mcp.middlewares=proxyheaders@consulcatalog"
]
check {
@ -81,6 +73,11 @@ EOH
path = "/api/health"
interval = "10s"
timeout = "2s"
check_restart {
limit = 3
grace = "60s"
}
}
}
}