tcardonne / docker-github-runner

Run GitHub Actions on self-hosted runner using Docker.
MIT License
297 stars 124 forks source link

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

Open DirkWolthuis opened 4 years ago

DirkWolthuis commented 4 years ago

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/gp-docker-action@1.1.6
        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?

tcardonne commented 4 years ago

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.

DirkWolthuis commented 4 years ago

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.

tcardonne commented 4 years ago

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.

alvarogarciafer commented 4 years ago

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

michael-robbins commented 3 years ago

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/?