Is a Docker action required to have DockerFile in the root?

Is it required to have the DockerFile in the root of the repo?

I’m creating my first action and was following the docs, which doesn’t explicitly state that this is required. Is that the case, as long as runs.image in action.yml points to the file.

Also, perhaps more importantly, does the filename need to be case sensitive (i.e. DockerFile is okay, but dockerfile is not)?
Reason I’m asking that is because I want to test the action in a workflow in the same repo. That is to verify the action works when I pused code changes. For reference, this is my repo for this. I’ve had a build with DockerFile, but that didn’t run because the Docker repository name must be lowercase. See this build.
After that I’ve moved to lowercase and the container ran (failue in the build is unrelated to this specific issue). See this build.

If there is a better/different way to test the actions locally, that is in the same repo, I’d love to hear that too. I’m new to actions but couldn’t find this specific information or practices in some other OSS actions I’ve looked into to debug this.

Thanks!

1 Like

@vidavidorra ,

A Dockerfile is a text file that Docker reads in from top to bottom. It contains a bunch of instructions which informs Docker HOW the Docker image should get built. The Dockerfile is essentially the build instructions to build the image, you can say a Dockerfile is a recipe (or blueprint if that helps) for building Docker images.

From the description of Dockerfile, I think a Dockerfile is required for a Docker action. And we generally use “Dockerfile” to name it, this is the most recommended name.

In addition, if you setup the action in its own repository, when you wants to use this action the workflow, you also can directly use the syntax " uses: {owner}/{repo}@{ref}". For example “uses: vidavidorra/github-action-renovate@master” in your case.

2 Likes

Thanks for the response. I probably wasn’t too clear about it in my initial message but I know how Docker works. Regardless, thanks for your clear explanation.

I’ve tried a whole bunch of different options, but apparently the name of the Dockerfile cannot contain any upercase characters other that the first uppercase character. So “Dockerfile” and “dockerfile” are both fine but “DockerFile” isn’t. That seemed to have been the issue as I now have successfull build (example).

I’ve also seen people use that, but that would only work for running the action on push of the master branch, and not for PRs.

uses: vidavidorra/github-action-renovate@master

I’m now using the following with my Dockerfile in a src directory. This should work for all branches and PRs as well.

used: ./