Docker action in same repository with Dockerfile in root

I want to run a docker action that I created in my own repository (the same as the workflow), its path, relative to the repository root would be /.github/actions/automatic-tests. I also have a Dockerfile in the root of the repository, which I use to create a docker image that runs the tests in my rails app.

In the documentation it is said that _“To reference a Dockerfile local to your repository, use a path relative to the root of the repository” _and the example would be:

image: 'Dockerfile'

However, it seems that, when running the action, the Dockerfile is searched in the actions folder, not in the root of the repository. The error is as follows:

/home/runner/work/_actions/raquelhortab/hello_world_github_actions/master/.github/actions/automatic-tests/Dockerfile: no such file or directory

I cannot put the Dockerfile inside the actions folder as I need to COPY the whole app. The workaround would be to use git to clone the repo but I think this should not be the solution when working in the exact same repository…

Can anyone tell me what I am doing wrong or what I should do to make it work?

Thanks!

Raquel

I finally got it to work with:

image: '../../../Dockerfile'

So it seems the path is relative not to the repository but to the action root, I hope this helps someone!

10 Likes

@raquelhortab wrote:

I finally got it to work with:

image: ‘…/…/…/Dockerfile’

So it seems the path is relative not to the repository but to the action root, I hope this helps someone!

This helped me, thanks @raquelhortab! I see that the documentation was recently updated so the copy for image now says:

Required for container actions  The Docker image to use as the container to run the action. The value can be the Docker base image name, a local Dockerfile in your repository, a public docker Hub or registry. To reference a Dockerfile local to your repository, use a path relative to your action metadata file. The application specified with the using syntax will execute this file.

1 Like