Build with multiple docker images


I have a nomad job that has 2 tasks within a task group and each task has a custom image. Can someone advise how I’d go about building both images in the build stage? Or how to skip build so I can just build the 2 images in my CI pipeline as I do currently.


Hey @robertg - If you’re building your containers else where, we recommend using the docker-pull plugin for your build stanzas instead. Also, if you are deploying multiple apps, you can use multiple app stanzas for separate builds.

Hi Brian,

We aren’t deploying multiple apps, simply 1 app with multiple parts that make up a single service. Examples of these may be php-fpm & apache, node & varnish or even our CRM & some related crons. These are all represented in our nomad jobs as either multiple tasks in a single group or as multiple groups but always in a single job that registers a single service with Consul (so not multiple apps).

I assume from your reply that currently the best approach would be to build the docker images separately. Can I also assume that it won’t be possible to use the ‘docker-pull’ step on both images and so, effectively, it would just be used as a “null” operation (because the build stage is not optional)?

May I request support in future for multiple ‘use’ statements or something in the build phase so I can use waypoint to build multiple images?

Waypoint has a view where 1 app means 1 build artifact. You. could do a build/deploy today with multiple app stanzas in a waypoint.hcl. Waypoint could build and deploy these containers at once this way.

project = "php-fpm-and-apache"

app "php-fpm" {
  build { ... }
  deploy { ... }

app "apache" {
  build { ... }
  deploy { ... }

Hmm, ok, I see how your suggestion would work. But I assume each deploy would then need it’s own nomad job and there would be no relation between the now separate jobs - so if one of the jobs failed the other would not also be rolled back like the tasks within task groups would be. I can see that wouldn’t matter in some cases - such as with one of the tasks being a varnish cache - but in other cases such as with apache and php where there is actually project code in both images (php in one, static assets in the other) it could cause a complete mess.

I think for now I’ll use docker-pull in the build step and basically treat it as a ‘no-op’ and then just use the nomad jobfile deploy in a single app.

But it would be great if support for multiple image builds within an ‘app’ were considered for the future, esp. given the planned deprecation of the one-project-multiple-apps concept in favour of one-repo-one-app :slight_smile: