I use a Dockerfile to build a Docker image for a .net service. I execute “gitversion” inside of the docker image, but it complains that the “.git” directory cannot be found. Is the “.git” directory somehow hidden in the Render build environment? Is there any way I can make it available to my build?
I have this command in my Dockerfile:
COPY ./.git .
Works on my computer, but in the Render build pipeline, this step fails with the following error:
Jul 13 09:40:30 AM Dockerfile:36
Jul 13 09:40:30 AM --------------------
Jul 13 09:40:30 AM 34 | WORKDIR /src
Jul 13 09:40:30 AM 35 | COPY . .
Jul 13 09:40:30 AM 36 | >>> COPY ./.git .
Jul 13 09:40:30 AM 37 |
Jul 13 09:40:30 AM 38 | # Build the "chuckinsights" project
Jul 13 09:40:30 AM --------------------
Jul 13 09:40:30 AM error: failed to solve: failed to compute cache key: "/.git": not found
Are you executing gitversion
when in the /src
folder?
I am @Frigidcode. It works on my machine but the docker build fails at the COPY command on the Render build pipeline. It makes me think they simply remove the .git folder after the git clone.
ah, I read your post too fast, I see the failed copy now. Do you have a custom docker build command setup? I wonder if it’s using -f
to specify the Dockerfile from a parent directory.
Nope, Dockerfile is in the root directory. Notably, everything else in the build works and deploys successfully except for this, so I’m pretty sure the config is right.
When I’ve run into that error, it’s been docker build
ran from a different directory using the -f
argument. No idea what else it could be, unless Render is doing that. I’ll keep an eye on this thread as now I’m interested in the reasoning behind it. Good luck
Hi there,
Thanks for reaching out.
I took a look at the build logic and it does seem we remove the .git
folder on Docker builds as we’ve seen scenarios where it caused issues with buildkit caching when present.
There isn’t a way to disable this deletion and would be curious to know the use case so I could feedback to the team. For example, if you’re looking to do something like adding the commit SHA to the app as an identifier of what’s deployed, the RENDER_GIT_COMMIT
env var should be available.
Kind regards
Alan
I have appreciated the support from the Render team, thank you!
RENDER_GIT_COMMIT
doesn’t meet my needs, but might be the right answer for other readers.
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.