nomad

HCL and Docker files for Nomad deployments
git clone https://git.in0rdr.ch/nomad.git
Log | Files | Refs | Pull requests |Archive | README

hivedav-demo.nomad (2758B)


      1 job "hivedav-demo" {
      2   datacenters = ["dc1"]
      3 
      4   priority = 80
      5 
      6   vault {}
      7 
      8   constraint {
      9     # image only built for arm
     10     attribute = "${attr.cpu.arch}"
     11     value     = "arm64"
     12   }
     13 
     14   group "server" {
     15     count = 1
     16 
     17     volume "tls" {		
     18       type = "csi"		
     19       source = "certbot"		
     20       access_mode = "multi-node-multi-writer"		
     21       attachment_mode = "file-system"		
     22     }
     23 
     24     network {
     25       port "https" {
     26         static = 44399
     27       }
     28       port "hivedav" {
     29         to = 3737
     30         static = 44398
     31       }
     32     }
     33 
     34     task "nginx" {
     35       driver = "podman"
     36 
     37       config {
     38         image = "docker.io/library/nginx:stable-alpine"
     39         ports = ["https"]
     40         volumes = [
     41           # mount the templated config from the task directory to the container
     42           "local/hivedav-demo.conf:/etc/nginx/conf.d/hivedav-demo.conf",
     43         ]
     44       }
     45 
     46       volume_mount {
     47         volume = "tls"
     48         destination = "/etc/letsencrypt"
     49       }
     50 
     51       template {
     52         destination = "${NOMAD_TASK_DIR}/hivedav-demo.conf"
     53         data = file("./templates/nginx.conf.tmpl")
     54       }
     55 
     56       resources {
     57         memory = 50
     58         memory_max = 128
     59         cpu    = 200
     60       }
     61     }
     62 
     63     task "hivedav-demo" {
     64       driver = "podman"
     65 
     66       config {
     67         image = "127.0.0.1:5000/hivedav:41710c7fb9ba4d85811ef64545bd0e8586b26192"
     68         force_pull = true
     69         ports = ["hivedav"]
     70         volumes = [
     71           # mount the templated config from the task directory to the container
     72           "local/app.env:/app/app.env",
     73         ]
     74         #command = "/bin/sh"
     75         #args = ["-c", "sleep 3600"]
     76       }
     77 
     78       env {
     79         HIVEDAV_HOST = "meet.in0rdr.ch"
     80         HIVEDAV_CALENDAR = 2
     81       }
     82 
     83       template {
     84         # render sensitive env vars in a template from Vault secrets
     85         env = true
     86         destination = "${NOMAD_SECRETS_DIR}/env"
     87         data = <<EOT
     88 HIVEDAV_CALDAV_HOST = "{{with secret "kv/hivedav-demo"}}{{index .Data.data.HIVEDAV_CALDAV_HOST}}{{end}}"
     89 HIVEDAV_CALDAV_USER = "{{with secret "kv/hivedav-demo"}}{{index .Data.data.HIVEDAV_CALDAV_USER}}{{end}}"
     90 HIVEDAV_CALDAV_PASSWORD = "{{with secret "kv/hivedav-demo"}}{{index .Data.data.HIVEDAV_CALDAV_PASSWORD}}{{end}}"
     91 HIVEDAV_SMTP_HOST = "{{with secret "kv/hivedav-demo"}}{{index .Data.data.HIVEDAV_SMTP_HOST}}{{end}}"
     92 HIVEDAV_SMTP_USER = "{{with secret "kv/hivedav-demo"}}{{index .Data.data.HIVEDAV_SMTP_USER}}{{end}}"
     93 HIVEDAV_SMTP_PASSWORD = "{{with secret "kv/hivedav-demo"}}{{index .Data.data.HIVEDAV_SMTP_PASSWORD}}{{end}}"
     94 EOT
     95       }
     96 
     97       template {
     98         destination = "${NOMAD_TASK_DIR}/app.env"
     99         data = file("./templates/app.env.tmpl")
    100       }
    101 
    102       resources {
    103         memory = 50
    104         memory_max = 128
    105         cpu    = 200
    106       }
    107     }
    108   }
    109 }