docker-github-runner icon indicating copy to clipboard operation
docker-github-runner copied to clipboard

Error when trying to build a docker image with self-hosted github runner

Open DirkWolthuis opened this issue 5 years ago • 5 comments

When using the config bellow to try and build a docker image I get an error that the Dockerfile can't be found. Be when running the same script in a Github runner from Github it runs. I've mounted the volume to the container of the self-hosted Github runner:

The error message: unable to prepare context: unable to evaluate symlinks in Dockerfile path: lstat /github/workspace/Dockerfile: no such file or directory

jobs:
  # This workflow contains a single job called "build"
  build-and-publish-head:
    runs-on: ubuntu-16.04 #self-hosted does not work here. 

    steps:
      - uses: actions/checkout@v2 # Checking out the repo

      - name: Build and Publish head Docker image
        uses: VaultVulp/[email protected]
        with:
          github-token: ${{ secrets.GITHUB_TOKEN }} # Provide GITHUB_TOKEN to login into the GitHub Packages
          image-name: fantasy-map-tool-react # Provide Docker image name
          image-tag: ${{ github.sha }} # Provide Docker image tag

Any thoughts?

DirkWolthuis avatar Jul 31 '20 12:07 DirkWolthuis

Hello,

The error you're getting indicates that a Dockerfile can't be found. Could you double check the location of the Dockerfile in your repository ?

Also, I'm not sure, but it seems that VaultVulp/gp-docker-action is using a Docker based action, meaning that it will spin-up a container to run the build and push commands. However, as you are already running the runner inside Docker, this might also be an issue.

tcardonne avatar Aug 02 '20 19:08 tcardonne

Hi! I think there is no problem with the dockerfile. It is in the root and works with Githubs own runner.

Domyou Guys use this project to build docker images? Do you have a action that works with this project?

PS. I got the same error message with the official docker action.

DirkWolthuis avatar Aug 03 '20 16:08 DirkWolthuis

Hello,

Although it runs on shared runners and not self-hosted runners, the following docker-build job should work with this project : https://github.com/tcardonne/restic-controller/blob/master/.github/workflows/main.yml#L27

I can't investigate further your issue at the moment, but I'm almost sure that it's because the gp-docker-action is an action spinning up a new Docker image.

tcardonne avatar Aug 10 '20 20:08 tcardonne

Hi.

I experienced a similar issue with another action.

What's happening is that your repo is checked out inside the github-runner container, and your action is starting a different container where the repo and Dockerfile don't exist.

In my case, my action was looking for a file in -v "/home/runner/_work/my-repo/my-repo":"/github/workspace", so I simply ran the github-runner container with --mount type=bind,source=/home/runner/_work/,destination=/home/runner/_work/ so that the host directory /home/runner/_work/ acts as a common volume where the repo exists for both containers.

Hope it's the right solution and it helps

alvarogarciafer avatar Sep 10 '20 19:09 alvarogarciafer

Is there a way to avoid using the Host OS you think? Possibly with volumes?

I guess we can't control how the runner's logic about mounting containers works though?

Context: I'd like to have multiple runners on the same box, but they all can't share /home/runner/_work/?

michael-robbins avatar Jan 11 '21 08:01 michael-robbins