Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Specifying Dockefile Path in Azure Pipelines

We are trying to use Azure Pipelines to build Docker image for a Dot Net Core App. When setting up the pipeline if I check "default build context" will it automatically pick the Dockerfile from my root directory?

Dockerfile is currently in the root directory but I want to move the Dockerfile inside the api project. How do I setup the pipeline so the docker build command is executed from root directory but refer to Dockerfile inside the project?

enter image description here

like image 303
code_blue Avatar asked May 23 '19 05:05

code_blue


1 Answers

I haven't tried this, but something like this should work:

- task: Docker@1
  inputs:
    containerregistrytype: 'Container Registry'
    dockerRegistryEndpoint: my_service_connection
    imageName: bla-bla-bla
    dockerFile: src/app/dockerfile
    buildContext: $(Build.Repository.LocalPath)

https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/build/docker?view=azure-devops#task-inputs

Version 2 of the task has support for setting build context:

enter image description here

like image 140
4c74356b41 Avatar answered Sep 21 '22 16:09

4c74356b41