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.28k stars 548 forks source link

Unable to get the required repo visible within Dockerfile #865

Closed sarthakpati closed 1 year ago

sarthakpati commented 1 year ago

Troubleshooting

I am trying to make the pull request location for a repo available to the Dockerfile: https://github.com/FeTS-AI/Front-End/pull/58/files#diff-dbade1e5797a7633e024a7685a43a7cbd96ae6fefc6314294807ae34cd83712c

Behaviour

Steps to reproduce this issue

  1. I have put this in the GitHub workflow file:
    - name: Build Docker images
      id: build
      uses: docker/build-push-action@v4
      with:
        context: .
        secrets: |
          GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}
          --mount=type=bind,source=/home/runner/work/Front-End/Front-End,target=/Front-End
  2. My Dockerfile has these lines that I am using to verify if it was mounted correctly:
    RUN --mount=type=bind,target=.
    RUN echo "running ls -l" && ls -l
  3. This gives me the following error:
    
    #9 [4/7] RUN --mount=type=bind,target=.
    #9 DONE 0.4s

10 [5/7] RUN echo "running ls -l" && ls -l

10 0.356 running ls -l

10 0.359 total 34152

10 0.359 drwxr-xr-x 1 root root 4096 Sep 27 2019 CaPTk

10 0.359 -rw-r--r-- 1 root root 34958860 Nov 2 2018 cmake-3.12.4-Linux-x86_64.sh

The file "cmake.xxx" and folder "CaPTk" are part of the base image I am downloading, whereas the expected repo location (i.e., "Front-End" is not present).

#### Expected behaviour

I should see this when running ls:

10 [5/7] RUN echo "running ls -l" && ls -l

10 0.356 running ls -l

10 0.359 total 34152

10 0.359 drwxr-xr-x 1 root root 4096 Sep 27 2019 CaPTk

10 0.359 drwxr-xr-x 1 root root 4096 Sep 27 2019 Front-End

10 0.359 -rw-r--r-- 1 root root 34958860 Nov 2 2018 cmake-3.12.4-Linux-x86_64.sh


#### Actual behaviour

9 [4/7] RUN --mount=type=bind,target=.

9 DONE 0.4s

10 [5/7] RUN echo "running ls -l" && ls -l

10 0.356 running ls -l

10 0.359 total 34152

10 0.359 drwxr-xr-x 1 root root 4096 Sep 27 2019 CaPTk

10 0.359 -rw-r--r-- 1 root root 34958860 Nov 2 2018 cmake-3.12.4-Linux-x86_64.sh



### Configuration

* Repository URL (if public):  https://github.com/FeTS-AI/Front-End
* Build URL (if public): https://github.com/FeTS-AI/Front-End/actions/runs/4954660481/jobs/8863361926
* Workflow file: https://github.com/FeTS-AI/Front-End/blob/fets_2.0/.github/workflows/docker-image.yml

### Logs

[logs_24.zip](https://github.com/docker/build-push-action/files/11458498/logs_24.zip)
> Download the [log file of your build](https://docs.github.com/en/actions/managing-workflow-runs/using-workflow-run-logs#downloading-logs) and [attach it](https://docs.github.com/en/github/managing-your-work-on-github/file-attachments-on-issues-and-pull-requests) to this issue.
crazy-max commented 1 year ago

--mount=type=bind,source=/home/runner/work/Front-End/Front-End,target=/Front-End

Not sure what you're trying to achieve but that's not a correct value for the secrets input. See https://docs.docker.com/build/ci/github-actions/secrets/

RUN --mount=type=bind,target=.
RUN echo "running ls -l" && ls -l

Defined mounts are only available for the RUN instruction where they are defined. I guess you want smth like:

RUN --mount=type=bind,target=. echo "running ls -l" && ls -l

This gives me the following error:

I don't see any error here


Looking at the issue description I guess you want to mount ./Front-End? If so you can just use a bind mount:

RUN --mount=type=bind,target=./Front-End echo "running ls -l" && ls -l

More info: https://docs.docker.com/engine/reference/builder/#run---mount