Skip to content

Expand .dockerignore to reduce unnecessary cache invalidation#4797

Open
singhvishalkr wants to merge 1 commit into
dexidp:masterfrom
singhvishalkr:fix-dockerignore-cache-invalidation
Open

Expand .dockerignore to reduce unnecessary cache invalidation#4797
singhvishalkr wants to merge 1 commit into
dexidp:masterfrom
singhvishalkr:fix-dockerignore-cache-invalidation

Conversation

@singhvishalkr

Copy link
Copy Markdown

Fixes #1968

The Dockerfile uses COPY . . which copies the entire source tree into the build context. This means any change to files that aren't needed for the build (like .git/, docs/, examples/) still invalidates the Docker layer cache.

This is particularly noticeable with .git/ -- every new commit, branch, or tag causes a full rebuild even though the actual source code hasn't changed.

The fix expands .dockerignore to exclude:

  • .git/ and .gitignore
  • docs/, examples/, and Markdown files
  • Editor and CI configs (.github/, .editorconfig, etc.)
  • Development-only files (docker-compose*.yaml, config.dev.yaml)
  • The Dockerfile itself

This keeps the build context minimal and focused on what the image actually needs: Go source files, dependencies (go.mod/go.sum), config.docker.yaml, and web/ templates.

@nabokihms nabokihms added the release-note/bug-fix Release note: Bug Fixes label May 20, 2026
@nabokihms

Copy link
Copy Markdown
Member

@singhvishalkr thanks for the PR!

Could you please run git rebase HEAD~1 --signoff to pass the DCO?

The Dockerfile copies the entire source tree with COPY . ., which means
any change to .git/, docs/, examples/, or other non-build files
invalidates the Docker layer cache.

Add exclusions for:
- .git/ (changes on every commit)
- Documentation and examples
- Editor/tool configs
- Development-only files

Signed-off-by: Vishal Kumar Singh <vishal.kr.singh2021@gmail.com>
@singhvishalkr singhvishalkr force-pushed the fix-dockerignore-cache-invalidation branch from 1e12bae to 0dc9ccf Compare June 17, 2026 05:38
@singhvishalkr

singhvishalkr commented Jun 17, 2026

Copy link
Copy Markdown
Author

Signed off the commit and force-pushed 0dc9ccf. The DCO check should rerun on the updated branch.

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

Labels

release-note/bug-fix Release note: Bug Fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Stop copying unneccesary files/folders during the building stage

2 participants