job "pasta" {
  region      = "global"
  datacenters = ["samfelag"]
  type        = "service"

  group "pasta" {
    count = 1

    restart {
      attempts = 5
      delay    = "15s"
    }

    network {
      port "backend" {
        to = 3000
      }
      port "client" {
        to = 80
      }
    }

    # PASTA SERVER
    task "pasta-server" {
      driver = "docker"

      env {
        PASTA_PORT = "3000"
        PASTA_DIR  = "/pasta"
      }

      config {
        image = "marc.sastre.cat/pasta-server"
        ports = ["backend"]
	    volumes = ["/mnt/vatnajokull/nomad_volumes/pasta:/pasta"]
      }

      resources {
        cpu    = 100
        memory = 256
      }

      service {
        name = "pasta-server"
        port = "backend"
      }
    }

    # PASTA CLIENT
    task "pasta-client" {
      driver = "docker"

      config {
        image = "marc.sastre.cat/pasta-client"
        ports = ["client"]
      }

      resources {
        cpu    = 50
        memory = 32
      }

      service {
        name = "pasta-client"
        port = "client"
      }
    }
  }
}

