I'm trying to deploy a docker image to Azure Container Registry via an Azure Devops pipeline. Now this works fine when I run it with this script:
trigger:
- master
variables:
# Container registry service connection established during pipeline creation
dockerRegistryServiceConnection: 'some_id'
imageRepository: 'worker'
containerRegistry: 'microcontainerapptest.azurecr.io'
dockerfilePath: '$(Build.SourcesDirectory)/Dockerfile'
tag: '$(Build.BuildId)'
# Agent VM image name
vmImageName: 'ubuntu-latest'
stages:
- stage: Build
displayName: Build and push stage
jobs:
- job: Build
displayName: Build
pool:
vmImage: $(vmImageName)
steps:
- task: Docker@2
displayName: Build and push an image to container registry
inputs:
command: buildAndPush
repository: $(imageRepository)
dockerfile: $(dockerfilePath)
containerRegistry: $(dockerRegistryServiceConnection)
tags: |
$(tag)
However, I want to actually use a deployment job so I can run the pipeline in different environments. Therefore I updated the .yml like this:
trigger:
- master
variables:
# Container registry service connection established during pipeline creation
dockerRegistryServiceConnection: 'some_id'
imageRepository: 'worker'
containerRegistry: 'microcontainerapptest.azurecr.io'
dockerfilePath: '$(Build.SourcesDirectory)/Dockerfile'
tag: '$(Build.BuildId)'
# Agent VM image name
vmImageName: 'ubuntu-latest'
stages:
- stage: Build
displayName: Build and push stage
jobs:
- deployment:
displayName: Build docker image
environment: $(DEPLOY_ENVIRONMENT)
strategy:
runOnce:
deploy:
steps:
- task: Docker@2
displayName: Build and push an image to container registry
inputs:
command: buildAndPush
repository: $(imageRepository)
dockerfile: $(Build.SourcesDirectory)/Dockerfile
containerRegistry: $(dockerRegistryServiceConnection)
tags: |
$(tag)
Making a deployment job out of this. Now when I run the pipeline like this I get an error
Unhandled: No Dockerfile matching /home/vsts/work/1/s/Dockerfile was found.
So it seems like the dockerfilePath is not valid anymore when I run it as a deployment job. I have searched but don't have a clue as to why this would be the case, does anybody know the answer to this?