Building multiple images from a monorepo where each service has its own Dockerfile Building multiple images from a monorepo where each service has its own Dockerfile docker docker

Building multiple images from a monorepo where each service has its own Dockerfile


  1. yes, you'd need to modify the azure-pipelines.yml for that.
  2. no. one for all or one for each dockerfile is okay
  3. not necessary, you could use a .sh script, but probably easier to just have docker tasks in the azure-pipelines.yml
  4. it is.

you would need to do something like this:

    steps:    - task: Docker@2      displayName: Build and push an image to container registry      inputs:        command: buildAndPush        repository: $(imageRepository1)        dockerfile: $(dockerfilePath1)        containerRegistry: $(dockerRegistryServiceConnection)        tags: |          $(tag1)    - task: Docker@2      displayName: Build and push an image to container registry      inputs:        command: buildAndPush        repository: $(imageRepository2)        dockerfile: $(dockerfilePath2)        containerRegistry: $(dockerRegistryServiceConnection)        tags: |          $(tag2)    - task: Docker@2      displayName: Build and push an image to container registry      inputs:        command: buildAndPush        repository: $(imageRepository3)        dockerfile: $(dockerfilePath3)        containerRegistry: $(dockerRegistryServiceConnection)        tags: |          $(tag3)

or can have multiple something.yml in the repo and have individual builds for each component (makes a lot more sense, tbh)

alternatively, with your file structure you can just reuse the same yaml file as a template and just feed it parameters. that would reduce code duplication and allow for easier management of your builds