dev.nomad.example 2.06 KB
Newer Older
1
2
3
4
5
6
# This should best be equal to project name, and also the binary name without extension. This defines the ${NOMAD_JOB_NAME}
job "pdf-generator" {
  datacenters = ["rwth-app-dev"]
  type = "system"

  update {
7
    stagger = "60s"
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
    max_parallel = 1
  }

  # Should probably be equal to the Job Name in most cases. This defines the ${NOMAD_GROUP_NAME}
  group "pdf-generator" {

    # Should probably be equal to the Job/Group Name in most cases. This defines the ${NOMAD_TASK_NAME}
    task "pdf-generator" {

      driver = "raw_exec"

      config {
        command = "dotnet"

        # This needs to point to the binary, and config file, relative or absolute.
        # Currently raw_exec will execute everything directly from the created alloc dir ${NOMAD_ALLOC_DIR},
        # but the content will be placed in the /local subdirectory {$NOMAD_TASK_DIR}
        #
        # You may want this to be full paths to your local repo build on dev
        args = [
28
29
          "PATH_TO_PDF-GENERATOR_MICROSERVICE\\pdf-generator\\bin\\Debug\\netcoreapp3.1\\pdf-generator.dll",
          "PATH_TO_PDF-GENERATOR_MICROSERVICE\\pdf-generator\\bin\\Debug\\netcoreapp3.1\\appsettings.json"
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
        ]
      }

      env{
        # Use localhost only for dev, and port set by Nomad
        ASPNETCORE_URLS = "http://${NOMAD_IP_http}:${NOMAD_PORT_http}",

        # Pass the basedir used by Traefik to the app
        ASPNETCORE_BASEPATH = "/${NOMAD_TASK_NAME}"
      }

      service {
        name = "${NOMAD_TASK_NAME}"
        port = "http"
        tags = [
          "traefik.enable=true",
46
          "traefik.http.routers.pdfgenerator.entrypoints=internal",
47
48
49
50
51
52
53
54
55
56
57
58
59
60
          "traefik.Path=/${NOMAD_TASK_NAME}"
        ]

        # The check URL needs to answer with status 200, preferbly use something like a version API call
        check {
          type     = "http"
          path     = "/swagger/index.html"
          interval = "10s"
          timeout  = "2s"
        }
      }

      resources {
        network {
61
          port "http" {
62
63
64
65
66
67
68
69
70
          }
        }
      }
    }
  }
    meta {
    VERSION = "DEV"
  }
}