Skip to content

Fix --no-cache flag in git deployments#1020

Open
He-Is-HaZaRdOuS wants to merge 1 commit into
Finsys:mainfrom
He-Is-HaZaRdOuS:fix_nobuildcache_flag
Open

Fix --no-cache flag in git deployments#1020
He-Is-HaZaRdOuS wants to merge 1 commit into
Finsys:mainfrom
He-Is-HaZaRdOuS:fix_nobuildcache_flag

Conversation

@He-Is-HaZaRdOuS

Copy link
Copy Markdown

Proposed change

This PR fixes the "Disable build cache" option in git deployments not working due to the passing of the "--no-cache" flag to the wrong docker compose command.
Now the system detects and forces a fresh image build with the "--no-cache" flag, before attempting to deploy (up) the stack again.

Closes #880

Type of change

  • Bug fix: non-breaking change which fixes an issue.
  • New feature / Enhancement: non-breaking change which adds functionality.
  • Breaking change: fix or feature that would cause existing functionality to not work as expected.
  • Other. Please explain:

Additional notes & discussion

Changes were made and tested according to the insights of @jotka in issue #880, Thanks!. However, I do not believe that this PR alone would provide the behaviour that one would expect when they want to disable build cache (at least not for me...).

The main reason that I say this is that I expect that the new deployment will be made purely of the new image to be built from the incoming git changes from upstream. However, what actually happens is that the changes from git are being copied over to the current (or old, depending on how you see it) build context in a dirty fashion, and then docker is instructed to build the image from this new source code.

I believe this behaviour is to maximize caching of source artifacts that don't change often (if at all!), and also to preserve non-git tracked files or artifacts such as local media, local databases, whatever the deployed service may generate or store in a host mount volume.

This "dirtiness" of the build context causes build issues for me when using Microsoft's .NET framework whenever I delete, rename, or move a file, the old stale counterparts still exist from the previous deployment in the current build context and cause a namespace collision when building the project because the deleted and newly added files may both define the same namespace, and that isn't allowed in .NET or whatever.

My hacky solution for this is to track the current source code and the incoming source code files, and basically nuke away any current files that don't exist in the git repo anymore, as to avoid the aforementioned namespace collisions. Why not nuke all the source code? Again, local media files may be stored in host mounts on the host machine, and those may contain sensitive info that one may not intend to delete when disabling build cache so.... I ignore any files that neither exist in the current and incoming source code.

This change-tracking commit is not part of this PR however, it's on https://github.com/He-Is-HaZaRdOuS/dockhand/commits/main/ in case any reviewer is interested in this niche case that I encountered, I'd be happy to provide more information or discuss it more (although my fork and local image build of dockhand is serving me just fine for the time being).

Anywho... This PR is fine as-is from an objective standpoint, and thanks for the opportunity!

@CLAassistant

CLAassistant commented May 10, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature Request] Add option to bypass Docker build cache (--no-cache)

2 participants