diff --git a/Jenkinsfile b/Jenkinsfile index 94aafc1..b1bfc7d 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -32,8 +32,7 @@ pipeline { // The next step is to make a POST request to http://nomad.service.consul/v1/jobs with content-type: application/json and content should { "Job": } steps { script { - sh 'curl -X POST -H "Content-Type: application/json" -d "{ \"JobHCL\": \"$(cat jobspec.hcl)\" }" http://nomad.service.consul/v1/jobs/parse > parsed_job.json' - sh 'curl -X POST -H "Content-Type: application/json" -d "{ \"Job\": $(cat parsed_job.json) }" http://nomad.service.consul/v1/jobs' + sh 'curl -X POST -H "Content-Type: application/json" -d @jobspec.json http://nomad.service.consul:4646/v1/jobs' } } } diff --git a/jobspec.hcl b/jobspec.hcl deleted file mode 100644 index d558e91..0000000 --- a/jobspec.hcl +++ /dev/null @@ -1,44 +0,0 @@ -job "homepage" { - datacenters = ["dc1"] - - group "web" { - count = 1 - - network { - port "http" { - to = 3000 - } - } - - task "homepage" { - driver = "docker" - - config { - image = "docker-registry.service.consul:4124/efstajas/homepage:latest" - ports = ["http"] - } - - service { - name = "homepage-new" - port = "http" - - tags = [ - "traefik.enable=true", - "traefik.http.routers.homepage-new.rule=Host(`new.jason-e.dev`) || Host(`jason-e.dev`)", - "traefik.http.routers.homepage-new.tls=true", - "traefik.http.routers.homepage-new.tls.certresolver=myresolver", - ] - } - - resources { - cpu = 200 - memory = 200 - } - - constraint { - attribute = "${attr.cpu.arch}" - value = "arm64" - } - } - } -} diff --git a/jobspec.json b/jobspec.json new file mode 100644 index 0000000..64a586b --- /dev/null +++ b/jobspec.json @@ -0,0 +1,62 @@ +{ + "Job": { + "ID": "homepage-new", + "Name": "homepage-new", + "Datacenters": ["dc1"], + "TaskGroups": [ + { + "Name": "web", + "Count": 1, + "Tasks": [ + { + "Name": "homepage", + "Driver": "docker", + "User": "", + "Config": { + "image": "docker-registry.service.consul:4124/efstajas/homepage:latest", + "ports": ["http"] + }, + "Constraints": [ + { + "LTarget": "${attr.cpu.arch}", + "RTarget": "amd64", + "Operand": "=" + } + ], + "Affinities": null, + "Env": null, + "Services": [ + { + "Name": "homepage-new", + "Tags": [ + "traefik.enable=true", + "traefik.http.routers.homepage-new.rule=Host(`new.jason-e.dev`) || Host(`jason-e.dev`)", + "traefik.http.routers.homepage-new.tls=true", + "traefik.http.routers.homepage-new.tls.certresolver=myresolver" + ], + "PortLabel": "http" + } + ], + "Resources": { + "CPU": 200, + "MemoryMB": 200 + } + } + ], + "Networks": [ + { + "DynamicPorts": [ + { + "Label": "http", + "Value": 0, + "To": 3000, + "HostNetwork": "", + "IgnoreCollision": false + } + ] + } + ] + } + ] + } +}