Open discentem opened 2 years ago
Hi @discentem,
Thank you for submitting this issue. I will mark this as an enhancement, since the issue here is that you don't have a way to control the context passed to the docker build
for example.
Hey @nikola-jokic, thanks for the reply!
I am curious though, what is the expected way to use this feature? Is the workaround I settled on common?
Hi again @nikola-jokic, any updates on providing a param for context?
I'm also wondering whether there are alternative strategies that I should consider. Is there an env variable or symlink I could utilize to access the root of the Github repo from whatever arbitrary directory I'm in?
Hey @discentem,
I can't think of one to leverage docker like this, without changing the runner and possibly the workflow.yaml
definition. One idea might be to get around this issue might be to have a Makefile
. It is common for go projects to have makefiles, so you can leverage that. Other than that, until we change the workings of the docker actions in the runner, the only thing I can think of is to use runner container hooks.
Hi again, this documentation actually implies the working directory should already be set to $GITHUB_WORKSPACE
(the root of the code repository): https://docs.github.com/en/actions/creating-actions/dockerfile-support-for-github-actions#workdir
In my experience that was not the case. However, should I simply be able to do cd $GITHUB_WORKSPACE
to solve my issue (get back to the root of my project code) instead of copying the Dockerfile around?
Hello, I'm also having this issue.
Describe the bug
I have a dockerfile defined in
dockerfiles/compile/Dockerfile
.Github Actions executes Docker from the directory where the Dockerfile is stored:
This causes my go build instruction in my Dockerfile to fail in Github Actions because my source files (namely go.mod) are not found in
dockerfiles/compile/Dockerfile
.See this gist for the full log: https://gist.github.com/discentem/4deff7191e527f0210e79fedfaca4026
To Reproduce
Fork https://github.com/discentem/hello-world-docker-action and push this commit to a new branch to trigger CI.
Expected behavior
I would expect Docker to be executed from the root of my repository and not specifically from the directory where the Dockerfile is sourced from. Something like this:
Or perhaps there should be a param to tell the runner what directory to run docker in
Workaround
If I copy my Dockerfile to the root of my repository on the fly and point the action to this copy, the action succeeds. This is because the Dockerfile is now being executed in a directory where
go.mod
and the go source files can be found.Runner Version and Platform
Hosted, Ubuntu 20.04
OS of the machine running the runner? Linux
What's not working?
Please include error messages and screenshots.
Job Log Output
Failed job output
Runner and Worker's Diagnostic Logs
N/A