Skip to content

docker buildx build failed because of "no such file or directory" error #1419

@neilime

Description

@neilime

Contributing guidelines

I've found a bug, and:

  • The documentation does not mention anything about my problem
  • There are no open or closed issues that are related to my problem

Description

I'm having a issue using the action, it looks like the action does not checking out the code.

  1. Creating a new repository
  2. Adding dockerfile in a dedicated tests folder
  3. Creating CI workflow (Based on https://docs.docker.com/build/ci/github-actions/multi-platform/#distribute-build-across-multiple-runners)
  4. Commit and push
  5. Get the following error: Error: buildx failed with: ERROR: failed to build: resolve : lstat tests: no such file or directory

https://github.com/hoverkraft-tech/test-docker-build-images/actions/runs/18471224671/job/52625652306

Expected behaviour

The workflow should not fail

Actual behaviour

Got the error: Error: buildx failed with: ERROR: failed to build: resolve : lstat tests: no such file or directory

Repository URL

https://github.com/hoverkraft-tech/test-docker-build-images

Workflow run URL

https://github.com/hoverkraft-tech/test-docker-build-images/actions/runs/18471224671/job/52625652306

YAML workflow

name: ci

on:
  push:

  workflow_dispatch:

env:
  REGISTRY_IMAGE: ghcr.io/hoverkraft-tech/test-docker-build-images/docker-docs-test

permissions:
  contents: read
  packages: write

jobs:
  build:
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        platform:
          - linux/amd64
          - linux/arm64
    steps:
      - name: Prepare
        run: |
          platform=${{ matrix.platform }}
          echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV

      - name: Docker meta
        id: meta
        uses: docker/metadata-action@v5
        with:
          images: ${{ env.REGISTRY_IMAGE }}

      - name: Login to registry
        uses: docker/login-action@v3
        with:
          username: ${{ github.repository_owner }}
          password: ${{ secrets.GITHUB_TOKEN }}
          registry: ghcr.io

      - name: Set up QEMU
        uses: docker/setup-qemu-action@v3

      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v3

      #   - uses: actions/checkout@v5 # FIXME: needed?

      - name: Build and push by digest
        id: build
        uses: docker/build-push-action@v6
        with:
          platforms: ${{ matrix.platform }}
          labels: ${{ steps.meta.outputs.labels }}
          tags: ${{ env.REGISTRY_IMAGE }}
          outputs: type=image,push-by-digest=true,name-canonical=true,push=true
          file: ./tests/application/Dockerfile
          context: .
          build-args: |
            BUILD_RUN_ID=${{ github.run_id }}

      - name: Export digest
        run: |
          mkdir -p ${{ runner.temp }}/digests
          digest="${{ steps.build.outputs.digest }}"
          touch "${{ runner.temp }}/digests/${digest#sha256:}"

      - name: Upload digest
        uses: actions/upload-artifact@v4
        with:
          name: digests-${{ env.PLATFORM_PAIR }}
          path: ${{ runner.temp }}/digests/*
          if-no-files-found: error
          retention-days: 1

  merge:
    runs-on: ubuntu-latest
    needs:
      - build
    steps:
      - name: Download digests
        uses: actions/download-artifact@v4
        with:
          path: ${{ runner.temp }}/digests
          pattern: digests-*
          merge-multiple: true

      - name: Login to registry
        uses: docker/login-action@v3
        with:
          username: ${{ github.repository_owner }}
          password: ${{ secrets.GITHUB_TOKEN }}
          registry: ghcr.io

      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v3

      - name: Docker meta
        id: meta
        uses: docker/metadata-action@v5
        with:
          images: ${{ env.REGISTRY_IMAGE }}
          tags: |
            type=ref,event=branch
            type=ref,event=pr
            type=semver,pattern={{version}}
            type=semver,pattern={{major}}.{{minor}}

      - name: Create manifest list and push
        working-directory: ${{ runner.temp }}/digests
        run: |
          docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
            $(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *)

      - name: Inspect image
        run: |
          docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }}

Workflow logs

logs_47513302738.zip

BuildKit logs


Additional info

Maybe the issue is because, it is the first commit in the repo

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions