Files
iiEasy/nomad/iieasy.nomad.hcl

171 lines
3.2 KiB
HCL
Raw Permalink Normal View History

# iiEasy Nomad Job
# Deploy: nomad job run -var "nomad_host=192.168.1.16" nomad/iieasy.nomad.hcl
variables {
# Docker image names (must exist on Nomad node - build via deploy-nomad.sh)
frontend_image = "iieasy-frontend:latest"
strapi_image = "iieasy-strapi:latest"
datacenter = "dc1"
}
job "iieasy" {
datacenters = [var.datacenter]
type = "service"
group "postgres" {
count = 1
volume "postgres_data" {
type = "host"
source = "iieasy-postgres-data"
read_only = false
}
network {
port "db" {
static = 5432
}
}
service {
name = "iieasy-postgres"
port = "db"
provider = "nomad"
check {
type = "script"
name = "postgres-ready"
command = "pg_isready"
args = ["-U", "strapi"]
interval = "5s"
timeout = "5s"
}
}
task "postgres" {
driver = "docker"
config {
image = "postgres:16-alpine"
ports = ["db"]
}
env {
POSTGRES_USER = "strapi"
POSTGRES_PASSWORD = "strapi"
POSTGRES_DB = "strapi"
}
volume_mount {
volume = "postgres_data"
destination = "/var/lib/postgresql/data"
read_only = false
}
resources {
cpu = 256
memory = 512
}
}
}
group "strapi" {
count = 1
volume "strapi_uploads" {
type = "host"
source = "iieasy-strapi-uploads"
read_only = false
}
network {
port "http" {
static = 1337
}
}
service {
name = "iieasy-strapi"
port = "http"
provider = "nomad"
}
task "strapi" {
driver = "docker"
config {
image = var.strapi_image
ports = ["http"]
}
template {
data = <<EOF
{{- with index (nomadService "iieasy-postgres") 0 }}
DATABASE_HOST={{ .Address }}
DATABASE_PORT={{ .Port }}
{{- end }}
EOF
destination = "local/db.env"
env = true
}
env {
HOST = "0.0.0.0"
PORT = "1337"
DATABASE_CLIENT = "postgres"
DATABASE_NAME = "strapi"
DATABASE_USERNAME = "strapi"
DATABASE_PASSWORD = "strapi"
APP_KEYS = "toBeModified1,toBeModified2"
API_TOKEN_SALT = "tobemodified"
ADMIN_JWT_SECRET = "tobemodified"
TRANSFER_TOKEN_SALT = "tobemodified"
JWT_SECRET = "tobemodified"
ENCRYPTION_KEY = "tobemodified"
}
volume_mount {
volume = "strapi_uploads"
destination = "/app/public/uploads"
read_only = false
}
resources {
cpu = 512
memory = 1024
}
}
}
group "frontend" {
count = 1
network {
port "http" {
static = 3000
to = 80
}
}
service {
name = "iieasy-frontend"
port = "http"
provider = "nomad"
}
task "frontend" {
driver = "docker"
config {
image = var.frontend_image
ports = ["http"]
}
resources {
cpu = 128
memory = 64
}
}
}
}