RocketChat Job, task priority and multiples command

Hello,

Today, my new adventure. RocketChat in nomad.

RocketChat needs mongo with replicaset to work.

This is the official docker-compose:
https://raw.githubusercontent.com/RocketChat/Rocket.Chat/develop/docker-compose.yml

That I understand about steps to boot.

1/ Mongo boots with command mongod --smallfiles --oplogSize 128 --replSet rs0 --storageEngine=mmapv1
2/ Mongo-init-replica boots with command

      bash -c
        "for i in `seq 1 30`; do
          mongo mongo/rocketchat --eval \"
            rs.initiate({
              _id: 'rs0',
              members: [ { _id: 0, host: 'localhost:27017' } ]})\" &&
          s=$$? && break || s=$$?;
          echo \"Tried $$i times. Waiting 5 secs...\";
          sleep 5;
        done; (exit $$s)"

to init replica

3/ RocketChat in last, boots with

 command: >
      bash -c
        "for i in `seq 1 30`; do
          node main.js &&
          s=$$? && break || s=$$?;
          echo \"Tried $$i times. Waiting 5 secs...\";
          sleep 5;
        done; (exit $$s)"

And where I am to write the job.

job "rocketchat" {
  region      = "global"
  datacenters = ["dc1"]
  type        = "service"

  group "rocketchat" {
    count = 1

    network {
      port "web" {
        to = 3000
      }
    }

    restart {
      attempts = 10
      interval = "5m"
      delay = "25s"
      mode = "delay"
    }

    task "rocketchat" {
        driver = "docker"

        lifecycle {
            hook    = "prestart"
            sidecar = false
        }

        env {
          PORT = "3000"
          ROOT_URL = "http://localhost:3000"
          MONGO_URL= "mongodb://mongo:27017/rocketchat"
          MONGO_OPLOG_URL= "mongodb://mongo:27017/local"
          MAIL_URL = "smtp://smtp.email"
        }

        config {
            image = "rocketchat/rocket.chat:3.9.3"

            volumes = [
              "/srv/live/rocket.chat/data/uploads:/app/uploads",  
            ]

            hostname = "rocketchat.service.consul"
            command      = "sh"
            args         = ["-c", "echo -n 'Waiting for service'; until nslookup mongo-rocketchat.service.consul 2>&1 >/dev/null; do echo '.'; sleep 2; done"]
            
            ports = ["web"]
        }

      service {
        name = "rocketchat"
        tags = [
            "traefik.enable=true",          
            "traefik.http.routers.rocketchat.entrypoints=http",
            "traefik.http.routers.rocketchat.rule=Host(`rocketchat.lan`)",
            "traefik.http.routers.rocketchat.middlewares=compress",
        ]

        port = "web"
        check {
            name     = "rocketchat port alive"
            type     = "http"
            path     = "/"
            interval = "10s"
            timeout  = "2s"
        }
      }

    }

    task "mongo" {
        driver = "docker"

        config {
            image = "mongo:4.4.2"

            volumes = [
              "/srv/live/rocket.chat/data/runtime/db:/data/db",
              "/srv/live/rocket.chat/data/dump:/dump",
            ]
            
            command = "mongod"
            args = "--smallfiles --oplogSize 128 --replSet rs0 --storageEngine=mmapv1"

            hostname = "mongo-rocketchat.service.consul"

        }

      service {
        name = "mongo"
        tags = [
            "traefik.enable=false",          
        ]
      }

    }

    task "mongo-init-replica" {
        driver = "docker"

        lifecycle {
            hook    = "prestart"
            sidecar = false
        }

        config {
            image = "mongo:4.4.2"
            
            command = "/bin/bash"
            args = ["-c", "for i in `seq 1 30`; do mongo mongo/rocketchat --eval \" rs.initiate({ _id: 'rs0', members: [ { _id: 0, host: 'localhost:27017' } ]})\" && s=$$? && break || s=$$?; echo \"Tried $$i times. Waiting 5 secs...\"; sleep 5; done; (exit $$s)"]
        }

      service {
        name = "mongo-init-replica"
        tags = [
            "traefik.enable=false",          
        ]
      }

    }
  }
}

I don’t really understand dependencies task in nomad. In docker compose, simply depends_onbut as I can read in nomad, need to create a command with args wait consul?
And for 3 tasks, how to order.
And last. How I can mix command to wait other task and command to task requiered for this docker container?

Thanks and sorry for this large question from newbie.