docker / build-push-action

GitHub Action to build and push Docker images with Buildx
https://github.com/marketplace/actions/build-and-push-docker-images
Apache License 2.0
4.11k stars 527 forks source link

docker/build-push-action@v4 ERROR: failed to solve: failed to read dockerfile #989

Closed josemotta closed 8 months ago

josemotta commented 8 months ago

Contributing guidelines

I've found a bug, and:

Description

I was using with success an external build runner on a RPi CM4 to run jobs from an action:

docker/build-push-action@v4

https://github.com/josemotta/iot-tofu/blob/main/.github/workflows/cd.yaml

But with no changes in the cd.yaml suddenly started showing an error](https://github.com/josemotta/iot-tofu/actions/runs/6500750870/job/17656744256)

Buildx version:
  /usr/bin/docker buildx version
  github.com/docker/buildx v0.11.2 9872040

Expected behaviour

https://github.com/josemotta/iot-tofu/actions/runs/6187543833/job/16797613768

Buildx version
  /usr/bin/docker buildx version
  github.com/docker/buildx v0.11.2 9872040
/usr/bin/docker buildx build --iidfile /tmp/docker-actions-toolkit-6wKOyG/iidfile --platform linux/arm64 --provenance mode=max,builder-id=https://github.com/josemotta/iot-tofu/actions/runs/6187543833 --tag ***/boot-back:e7bdb578003498a634dbbe2dc152bb5fc380eba2 --tag ***/boot-back:latest --metadata-file /tmp/docker-actions-toolkit-6wKOyG/metadata-file --push .
#0 building with "builder-c66e398f-d3c9-48d1-bd78-ecff650b3ccd" instance using docker-container driver

#1 [internal] load build definition from Dockerfile
#1 transferring dockerfile: 765B 0.0s done
#1 DONE 0.0s

#2 [internal] load metadata for docker.io/library/node:18-slim
#2 ...

#3 [auth] library/node:pull token for registry-1.docker.io
#3 DONE 0.0s

#2 [internal] load metadata for docker.io/library/node:18-slim
#2 DONE 2.3s

#4 [internal] load .dockerignore
#4 transferring context: 189B 0.0s done
#4 DONE 0.0s

#5 [internal] load build context
#5 DONE 0.0s

#6 [1/9] FROM docker.io/library/node:18-slim@sha256:e5c8c319295f6cbc288e19506a9ac37afa3b330f4e38afb01d[126](https://github.com/josemotta/iot-tofu/actions/runs/6187543833/job/16797613768#step:4:131)9b579cf6a5b
#6 resolve docker.io/library/node:18-slim@sha256:e5c8c319295f6cbc288e19506a9ac37afa3b330f4e38afb01d1269b579cf6a5b 0.0s done
#6 DONE 0.0s

#5 [internal] load build context
#5 ...

Actual behaviour

https://github.com/josemotta/iot-tofu/actions/runs/6500750870/job/17656744256

Buildx version
  /usr/bin/docker buildx version
  github.com/docker/buildx v0.11.2 9872040
/usr/bin/docker buildx build --file ./Dockerfile --iidfile /tmp/docker-actions-toolkit-5hnLDO/iidfile --platform linux/arm64 --provenance mode=max,builder-id=https://github.com/josemotta/iot-tofu/actions/runs/6500750870 --tag ***/boot-back:3db631693d95c85795f93f02542bd7da18fbac28 --tag ***/boot-back:latest --metadata-file /tmp/docker-actions-toolkit-5hnLDO/metadata-file --push .
#0 building with "builder-ba80848f-0ec1-4fac-98d8-5b7d4c39fcbc" instance using docker-container driver
#1 [internal] load build definition from Dockerfile
#1 transferring dockerfile: 2B done
#1 DONE 0.0s
ERROR: failed to solve: failed to read dockerfile: open Dockerfile: no such file or directory
Error: buildx failed with: ERROR: failed to solve: failed to read dockerfile: open Dockerfile: no such file or directory

Repository URL

https://github.com/josemotta/iot-tofu

Workflow run URL

https://github.com/josemotta/iot-tofu/blob/main/.github/workflows/cd.yaml

YAML workflow

name: CDGitops

on:
  push:
    branches: [main]

jobs:
  build:
    name: Build
    runs-on: [self-hosted, linux, ARM64]

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

      - name: Login to Docker Hub
        uses: docker/login-action@v2
        with:
          username: ${{ secrets.DOCKER_USERNAME }}
          password: ${{ secrets.DOCKER_PASSWORD }}

      - name: Build and push
        uses: docker/build-push-action@v4
        with:
          context: .
          file: ./Dockerfile
          push: true
          tags: ${{ secrets.DOCKER_USERNAME }}/boot-back:${{ github.sha }}, ${{ secrets.DOCKER_USERNAME }}/boot-back:latest
          platforms: linux/arm64

Workflow logs

Version:  v0.11.2
      Path:     /usr/libexec/docker/cli-plugins/docker-buildx
    compose: Docker Compose (Docker Inc.)
      Version:  v2.21.0
      Path:     /usr/libexec/docker/cli-plugins/docker-compose
  Server:
   Containers: 3
    Running: 2
    Paused: 0
    Stopped: 1
   Images: 4
   Server Version: 24.0.6
   Storage Driver: overlay2
    Backing Filesystem: extfs
    Supports d_type: true
    Using metacopy: false
    Native Overlay Diff: true
    userxattr: false
   Logging Driver: json-file
   Cgroup Driver: systemd
   Cgroup Version: 2
   Plugins:
    Volume: local
    Network: bridge host ipvlan macvlan null overlay
    Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
   Swarm: inactive
   Runtimes: io.containerd.runc.v2 runc
   Default Runtime: runc
   Init Binary: docker-init
   containerd version: 61f9fd88f79f081d64d6fa3bb1a0dc71ec870[52](https://github.com/josemotta/iot-tofu/actions/runs/6500750870/job/17656744256#step:4:54)3
   runc version: v1.1.9-0-gccaecfc
   init version: de40ad0
   Security Options:
    seccomp
     Profile: builtin
    cgroupns
   Kernel Version: 6.1.21-v8+
   Operating System: Debian GNU/Linux 11 (bullseye)
   OSType: linux
   Architecture: aarch64
   CPUs: 4
   Total Memory: 1.806GiB
   Name: raspberrypi
   ID: 9d32e3f2-a167-4480-889a-606fc667217f
   Docker Root Dir: /var/lib/docker
   Debug Mode: false
   Username: ***
   Experimental: false
   Insecure Registries:
    127.0.0.0/8
   Live Restore Enabled: false
  WARNING: No memory limit support
  WARNING: No swap limit support
Proxy configuration

Buildx version
  /usr/bin/docker buildx version
  github.com/docker/buildx v0.11.2 9872040

/usr/bin/docker buildx build --file ./Dockerfile --iidfile /tmp/docker-actions-toolkit-5hnLDO/iidfile --platform linux/arm64 --provenance mode=max,builder-id=https://github.com/josemotta/iot-tofu/actions/runs/6500750870 --tag ***/boot-back:3db631693d95c85795f93f02[54](https://github.com/josemotta/iot-tofu/actions/runs/6500750870/job/17656744256#step:4:56)2bd7da18fbac28 --tag ***/boot-back:latest --metadata-file /tmp/docker-actions-toolkit-5hnLDO/metadata-file --push .
#0 building with "builder-ba[80](https://github.com/josemotta/iot-tofu/actions/runs/6500750870/job/17656744256#step:4:82)[84](https://github.com/josemotta/iot-tofu/actions/runs/6500750870/job/17656744256#step:4:86)8f-0ec1-4fac-[98](https://github.com/josemotta/iot-tofu/actions/runs/6500750870/job/17656744256#step:4:100)d8-5b7d4c39fcbc" instance using docker-container driver
#1 [internal] load build definition from Dockerfile
#1 transferring dockerfile: 2B done
#1 DONE 0.0s
ERROR: failed to solve: failed to read dockerfile: open Dockerfile: no such file or directory
Error: buildx failed with: ERROR: failed to solve: failed to read dockerfile: open Dockerfile: no such file or directory

BuildKit logs

No response

Additional info

No response

ega130 commented 8 months ago

https://github.com/docker/build-push-action/issues/169#issuecomment-711729397

crazy-max commented 8 months ago

As explained in the README, when using a path context (context: .), you need a "Checkout" step. But you can also use the git context.

josemotta commented 8 months ago

Thanks! Following your suggestion, I just removed the context and it worked fine.

  - name: Build and push
    uses: docker/build-push-action@v4
    with:
      # context: .