# Generic HCL2 orchestrator job definition. Inert: every task references a fictional image and
# no command does anything outside the described container.
job "orders-api" {
  region      = "eu-example-1"
  datacenters = ["dc-example-1", "dc-example-2"]
  type        = "service"
  priority    = 60

  update {
    max_parallel      = 2
    min_healthy_time  = "30s"
    healthy_deadline  = "5m"
    auto_revert       = true
    canary            = 1
  }

  group "api" {
    count = 3

    network {
      mode = "bridge"

      port "http" {
        to = 8080
      }
    }

    restart {
      attempts = 3
      interval = "10m"
      delay    = "30s"
      mode     = "fail"
    }

    task "server" {
      driver = "docker"

      config {
        image = "registry.example.invalid/example-org/orders:1.4.0"
        ports = ["http"]
      }

      env {
        LOG_LEVEL = "info"
        TIER      = "standard"
      }

      resources {
        cpu    = 500
        memory = 512
      }

      service {
        name = "orders-api"
        port = "http"

        check {
          type     = "http"
          path     = "/healthz"
          interval = "10s"
          timeout  = "2s"
        }
      }
    }
  }
}
