Azure DevOps Pipelines : ##[error]Unhandled: No Dockerfile matching /home/vsts/work/1/s/Dockerfile_glpi_v1 was found

Dunvael LE ROUX 45 Reputation points
2023-08-08T14:54:55.6533333+00:00

Hello, I'm in internship trying to learn how to become a cloud administrator (DevOps). To do that I practice and try to deploy resources with different tools to learn the basics, the best practises and so much more.

I decided to try Azure DevOps Pipelines in order to deploy GLPI with its database on a AKS cluster. I successfully created my project (my code is stored on GitHub) and the necessary services connections Kubernetes (with KubeConfig) and Docker for my pipeline.

I had no issue deploying my aks cluster with .yaml files with kubectl commands on the azure Cloud Shell.

Now I want to use Pipelines to build and push my GLPI image to a Docker repository I created. I variabilize and as I have a .env file for GLPI I use the commands build and push separately.

Now when I run my pipeline I get the following error : ##[error]Unhandled: No Dockerfile matching /home/vsts/work/1/s/Dockerfile_glpi_v1 was found.

I checked so many posts about this error to understand and finally tried to use buildContext: (Build.SourcesDirectory) however the issue persists. I checked my directory with pwd and got as a result : /home/vsts/work/1/s.

My pipeline code is the following :

trigger:
  batch: true
  branches:
    include:
    - main
  paths:
    include:
    - azure-pipelines.yml

pool:
  vmImage: ubuntu-latest

resources:
- repo: self

variables:
  imageRepository1: 'dunvael/glpi_v10.0.7'
  dockerfilePath1: './Dockerfile_glpi_v1'
  kubernetesServiceEndpoint: 'KubernetesConnection'
  envFilePath1: './mariadb-glpi-one.env'

# Build the docker image
stages:
- stage: Build
  jobs:
  - job: BuildAndPush
    displayName: 'Build and Push the Docker image to DockerHub'
    pool:
      vmImage: 'ubuntu-latest'
    steps:
    - script: |
        echo "Current working directory: $(pwd)"
      displayName: Print Current Working Directory
    - task: Docker@2
      inputs:
        containerRegistry: 'DockerHubConnection'
        repository: $(imageRepository1)
        Dockerfile: $(dockerfilePath1)
        buildContext: $(Build.SourcesDirectory) # Set the build context to the root of the repository => telling Azure DevOps to use the root directory of my source code repository as the context for building the Docker image
        command: build
        arguments: '--build-arg ENV_FILE_PATH=$(envFilePath1)'
        tags: 'latest'

    - task: Docker@2
      inputs:
        containerRegistry: 'DockerHubConnection'
        repository: $(imageRepository1)
        Dockerfile: $(dockerfilePath1)
        command: push

# Admin acknowledgement 1
- stage: AdminVal
  displayName: 'Admin Validation'
  dependsOn: Build
  jobs:
  - job: waitForValidation
    displayName: Wait for external validation  
    pool: server    
    timeoutInMinutes: 1440 # job times out in 3 days
    steps:   
    - task: ManualValidation@0
      timeoutInMinutes: 120 # task times out in 1 day
      inputs:
        notifyUsers: |
          ******@gmail.com
        instructions: 'Glpi V1 image build and push to Docker repository failed. Do you want to continue?'
        onTimeout: 'reject'

# Deploy to cluster AKS
- stage: DeployAKS
  dependsOn: AdminVal
  jobs:
  - job: GLPIdeploy
    displayName: 'Deploy Glpi image to AKS'
    pool:
      vmImage: 'ubuntu-latest'
    steps:
    - script: |
        echo "Current working directory: $(pwd)"
      displayName: Print Current Working Directory
    - task: Kubernetes@1
      displayName: Deploy to AKS
      inputs:
        connectionType: 'Kubernetes Service Connection'
        kubernetesServiceEndpoint: '$(kubernetesServiceEndpoint)'
        namespace: 'glpi'
        command: 'apply'
        arguments: '-f ./infra/cluster/glpi_v1.yaml'
        secretType: 'dockerRegistry'
        containerRegistryType: 'Container Registry'
        dockerRegistryEndpoint: 'DockerHubConnection'
    - script: |
        echo "Current working directory: $(pwd)"
      displayName: Print Current Working Directory
    - task: Kubernetes@1
      inputs:
        connectionType: 'Kubernetes Service Connection'
        kubernetesServiceEndpoint: $(kubernetesServiceEndpoint)
        namespace: 'glpi'
        command: 'login'

# The following task executes the infra_creation.sh script in a Bash shell and will allow users to interact with the prompts when the script runs
    - task: Bash@3
      inputs:
        filePath: './infra/cluster/infra_creation.sh'

# Test GLPI v1 service
- stage: Testv1
  dependsOn: DeployAKS
  jobs:
  - job: TestV1Service
    displayName: 'Test Glpi V1 Service'
    pool:
      vmImage: 'ubuntu-latest'
    steps:
    - script: |
        curl https://glpi-v1.xxxxx.xxxxx/
      displayName: Test Glpi V1 Service with curl

# Signout
- stage: SignOut
  dependsOn: Testv1
  jobs:
    - job: SigningOut
      displayName: 'Signing Out'
      pool:
        vmImage: 'ubuntu-latest'
      steps:
      - task: CmdLine@2
        inputs:
          script: |
            echo Thank you for using Azure DevOps Pipeline.
            echo
            echo Have a good day !

The path of my Dockerfile_glpi_v1 (I use VS Code to push it to GitHub) is : Projet > Projet_fil_rouge_GLPI There are several dockerfiles and .env file because I wish to deploy several versions of GLPI but I start with only one first.

2023-08-08-16h37_tree

Could you please enlighten me ? I apologize if this is because of my inexperience or a mistake on my part.

Thank you very much.

Community Center Not monitored
{count} vote

2 answers

Sort by: Most helpful
  1. Avinash Pamula 0 Reputation points
    2024-05-29T13:04:24.66+00:00

    i am still getting same issue can someone help me with that

    ##[warning]No data was written into the file /home/vsts/work/_temp/task_outputs/build_1716986007375.txt

    Docker

    Build and push an image to Azure Container Registry

    https://docs.microsoft.com/azure/devops/pipelines/languages/docker

    trigger:

    • main

    resources:

    • repo: self

    variables:

    Container registry service connection established during pipeline creation

    dockerRegistryServiceConnection: '484f7284-2d0d-4a5a-9c89-465005269850'

    imageRepository: 'avinash123'

    containerRegistry: 'azure12.azurecr.io'

    dockerfilePath: '$(Build.SourcesDirectory)/tg-redirect-master/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)
          
    0 comments No comments

  2. Avinash Pamula 0 Reputation points
    2024-05-29T13:21:30.5133333+00:00

    i am still getting same error

    ##[warning]No data was written into the file /home/vsts/work/_temp/task_outputs/build_1716986007375.txt can someone help me with that solution

    # Docker
    # Build and push an image to Azure Container Registry
    # https://docs.microsoft.com/azure/devops/pipelines/languages/docker
    trigger:
    - main
    resources:
    - repo: self
    variables:
      # Container registry service connection established during pipeline creation
      dockerRegistryServiceConnection: '484f7284-2d0d-4a5a-9c89-465005269850'
      imageRepository: 'avinash123'
      containerRegistry: 'azure12.azurecr.io'
      dockerfilePath: '$(Build.SourcesDirectory)/tg-redirect-master/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)
    
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.