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.42k stars 561 forks source link

COPY will be invalid due to `#!/bin/bash` #1225

Closed Mon-ius closed 2 months ago

Mon-ius commented 2 months ago

Contributing guidelines

I've found a bug, and:

Description

I have an action file for build v3 from the sub-sub-directory Dockerfile,

The structure of project is:

├── dev
│   ├── Meta
│   ├── click.sh
│   ├── v1
│   │   ├── Dockerfile
│   │   └── entrypoint.sh
│   ├── v2
│   │   ├── Dockerfile
│   │   └── entrypoint.sh
│   ├── v3
│   │   ├── Dockerfile
│   │   └── entrypoint.sh

The action file is:

name: build-v3

on:
  workflow_dispatch:
  schedule:
    - cron: '0 6 */6 * *'
  push:
    branches:
      - "master"
    paths:
      - ".github/workflows/build-v3.yml"
      - "dev/v3/Dockerfile"
      - "dev/v3/entrypoint.sh"

jobs:
  build-v3:
    runs-on: ubuntu-latest
    steps:
      -
        name: Checkout
        uses: actions/checkout@v4
      -
        name: Set up QEMU
        uses: docker/setup-qemu-action@v3
      -
        name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v3
      -
        name: Login to Docker Hub
        uses: docker/login-action@v3
        with:
          username: ${{ secrets.DOCKERHUB_USERNAME }}
          password: ${{ secrets.DOCKERHUB_TOKEN }}
      -
        name: Build and push v3 file
        uses: docker/build-push-action@v6
        with:
          context: .
          file: ./dev/v3/Dockerfile
          push: true
          platforms: linux/amd64, linux/arm64, linux/s390x, linux/arm, linux/ppc64le, linux/riscv64
          tags: ${{ secrets.DOCKERHUB_USERNAME }}/docker-warp-socks:v3

Inside the dev/v3/Dockerfile, see Dockerfile

COPY dev/v3/entrypoint.sh /opt/entrypoint.sh
ENTRYPOINT ["/opt/entrypoint.sh"]

Expected behaviour

It should copy the dev/v3/entrypoint.sh from git to /opt/entrypoint.sh inside the container.

Actual behaviour

exec /opt/entrypoint.sh: no such file or directory exec /opt/entrypoint.sh: no such file or directory exec /opt/entrypoint.sh: no such file or directory exec /opt/entrypoint.sh: no such file or directory

Repository URL

https://github.com/Mon-ius/Docker-Warp-Socks/blob/947deee8b7e222f43250fffdb0986c7fa1ce9b61

Workflow run URL

https://github.com/Mon-ius/Docker-Warp-Socks/actions/runs/10761703139

YAML workflow

https://github.com/Mon-ius/Docker-Warp-Socks/blob/947deee8b7e222f43250fffdb0986c7fa1ce9b61/.github/workflows/build-v3.yml

Workflow logs

No response

BuildKit logs

No response

Additional info

No response

Mon-ius commented 2 months ago

After over 10 retries, I discovered the main issue: v6 won't copy the entrypoint.sh file if bash isn't available. I temporarily fixed it by changing #!/bin/bash to #!/bin/sh.

crazy-max commented 2 months ago

From the logs I don't see any issue at build time: https://github.com/Mon-ius/Docker-Warp-Socks/actions/runs/10761703139/job/29841206755#step:6:506

#34 [linux/s390x 4/4] COPY dev/v3/entrypoint.sh /run/entrypoint.sh
#34 DONE 0.0s

exec /opt/entrypoint.sh: no such file or directory exec /opt/entrypoint.sh: no such file or directory exec /opt/entrypoint.sh: no such file or directory exec /opt/entrypoint.sh: no such file or directory

I guess this happens at runtime which is related to what you figure out https://github.com/docker/build-push-action/issues/1225#issuecomment-2336773293

Closing but feel free to reply if you think there is still an issue