I am building an Azure DevOps pipeline and was trying out the multi-stage feature, this is defined by using a yml file.
In the yml definition I have two stages, one is to build docker images using a docker-compose command, second stage is to push these images to ACR. It seems this is not possible as I haven't had any success accessing the recently built images from the first stage. Here's a sample yml file
stages:
- stage: Build
displayName: Build image
jobs:
- job: Build
displayName: Build
pool:
vmImage: 'ubuntu-latest'
steps:
- publish: $(Build.ArtifactStagingDirectory)
artifact: docker-images
- task: DockerCompose@0
inputs:
containerregistrytype: 'Azure Container Registry'
azureSubscription: '************'
azureContainerRegistry: '************'
dockerComposeFile: '**/docker-compose.yml'
action: 'Build services'
additionalImageTags: '$(Build.BuildId)'
- stage: Push
displayName: Push image
jobs:
- job: Push
displayName: Push
pool:
vmImage: 'ubuntu-latest'
steps:
- download: current
artifact: docker-images
- task: DockerCompose@0
inputs:
containerregistrytype: 'Azure Container Registry'
azureSubscription: '************'
azureContainerRegistry: '************'
dockerComposeFile: '**/docker-compose.yml'
action: 'Push services'
additionalImageTags: '$(Build.BuildId)'
The question is, how do I access docker images that was built in my previous stage? where is it stored? I've tried by downloading $(Build.ArtifactStagingDirectory)
from the first stage but it didn't seem to have it. The same applies if I have one stage but separate jobs.
If I would to use both build and push in one stage it works fine, but I want to have a separate stages for each.