github.com/anth0d/nomad@v0.0.0-20221214183521-ae3a0a2cad06/e2e/isolation/input/chroot_dl_exec.nomad (about)

     1  job "chroot_dl_exec" {
     2    datacenters = ["dc1"]
     3    type        = "batch"
     4    constraint {
     5      attribute = "${attr.kernel.name}"
     6      value     = "linux"
     7    }
     8    group "group" {
     9      network {
    10        mode = "host"
    11        port "http" {}
    12      }
    13      task "script-writer" {
    14        driver = "raw_exec"
    15        config {
    16          command = "/bin/bash"
    17          args = [
    18            "-c",
    19            "cd ${NOMAD_ALLOC_DIR} && chmod +x script.sh && tar -czf script.tar.gz script.sh"
    20          ]
    21        }
    22        resources {
    23          cpu    = 10
    24          memory = 12
    25        }
    26        template {
    27          data        = <<EOH
    28  #!/bin/sh
    29  echo this output is from a script
    30  EOH
    31          destination = "${NOMAD_ALLOC_DIR}/script.sh"
    32        }
    33        lifecycle {
    34          hook    = "prestart"
    35          sidecar = false
    36        }
    37      }
    38      task "file-server" {
    39        driver = "raw_exec"
    40        config {
    41          command = "/usr/bin/python3"
    42          args    = ["-m", "http.server", "${NOMAD_PORT_http}", "--directory", "${NOMAD_ALLOC_DIR}"]
    43        }
    44        resources {
    45          cpu    = 10
    46          memory = 32
    47        }
    48        lifecycle {
    49          hook    = "prestart"
    50          sidecar = true
    51        }
    52      }
    53      task "run-script" {
    54        driver = "exec"
    55        config {
    56          command = "local/script.sh"
    57        }
    58        resources {
    59          cpu    = 10
    60          memory = 12
    61        }
    62        artifact {
    63          source = "http://localhost:${NOMAD_PORT_http}/script.tar.gz"
    64        }
    65      }
    66    }
    67  }