Simple nomad config for a Nginx and php-fpm app

Hello!

I have webapp (php-fpm and nginx) that I am trying to run with Nomad, I need to share a app folder in the php container into the Nginx, one, how can I do that? both the Php and Nginx tasks are in the same Job group.

And the error I am facing is that the Nginx job fails because it is not mounting the files.

Any ideas whats the proper way to archive what I intended?

This is my current config:

job "mywebapp" {
  datacenters = [
    "aws_us_east_2"]
  type = "service"
  update {
    max_parallel = 1
    min_healthy_time = "10s"
    healthy_deadline = "3m"
    progress_deadline = "10m"
    auto_revert = false
    canary = 0
  }
  migrate {
    max_parallel = 1
    health_check = "checks"
    min_healthy_time = "10s"
    healthy_deadline = "5m"
  }
  group "app" {
    count = 1
    restart {
      attempts = 2
      interval = "30m"
      delay = "15s"
      mode = "fail"
    }
    ephemeral_disk {
      size = 300
    }
    task "nginx" {
      driver = "docker"
      config {
        image = "nginx:latest"
        hostname = "nginx.service.consul"
        port_map {
          nginx_port = 8080
        }
        dns_servers = [
          "127.0.0.1:8600"]
        dns_search_domains = [
          "consul"]
        volumes = [
          "app_dir:/var/www/mywebapp",
        ]
      }
      resources {
        cpu = 500
        memory = 256
        network {
          mbits = 10
          port "nginx_port" {
            static = 8080
          }
        }
      }
      service {
        name = "nginx"
        tags = [
          "global",
          "app"]
        port = "nginx_port"

        check {
          name = "alive"
          type = "tcp"
          interval = "10s"
          timeout = "2s"
        }
      }
      template {
        source        = "/home/user/app/nomad/templates/nginx/default.conf"
        destination = "/etc/nginx/conf.d/default.conf"
      }
    }
    task "mywebapp_task" {
      driver = "docker"
      config {
        image = "mywebapp"
        hostname = "mywebapp.service.consul"
        port_map {
          phpfpm = 9000
        }
        dns_servers = ["${attr.unique.network.ip-address}"]
        dns_search_domains = [
          "consul"]
        volumes = [
          "app_dir:/var/www/mywebapp",
        ]
      }
      resources {
        cpu = 1000
        memory = 1024
        network {
          mbits = 10
          port "phpfpm" {}
        }
      }
      service {
        name = "mywebapp"
        tags = [
          "global",
          "app"]
        port = "phpfpm"

        check {
          name = "alive"
          type = "tcp"
          interval = "10s"
          timeout = "2s"
        }
      }
    }
  }
}