Skip to content

pkg: exclude Dockerfile from COPY in all packages#5732

Merged
rene merged 1 commit intolf-edge:masterfrom
christoph-zededa:fix_dockerfile_copy
Apr 20, 2026
Merged

pkg: exclude Dockerfile from COPY in all packages#5732
rene merged 1 commit intolf-edge:masterfrom
christoph-zededa:fix_dockerfile_copy

Conversation

@christoph-zededa
Copy link
Copy Markdown
Contributor

@christoph-zededa christoph-zededa commented Apr 1, 2026

Description

Use COPY --exclude=Dockerfile to prevent the Dockerfile itself from being copied into the image. Add syntax=docker/dockerfile:1.19.0 directive to Dockerfiles that lacked it to enable the --exclude flag.

This way the docker hashes bumper does not have to run several times anymore.

How to test and validate this PR

Check that the image still compiles correctly.

Changelog notes

Build improvement

PR Backports

For all current LTS branches, please state explicitly if this PR should be
backported or not. This section is used by our scripts to track the backports,
so, please, do not omit it.

Here is the list of current LTS branches (it should be always up to date):

  • 16.0-stable: no
  • 14.5-stable: no
  • 13.4-stable: no

Checklist

  • I've provided a proper description
  • I've added the proper documentation
  • I've tested my PR on amd64 device
  • I've tested my PR on arm64 device
  • I've written the test verification instructions
  • I've set the proper labels to this PR

And the last but not least:

  • I've checked the boxes above, or I've provided a good reason why I didn't
    check them.

Please, check the boxes above after submitting the PR in interactive mode.

@christoph-zededa christoph-zededa requested review from jsfakian and removed request for eriknordmark April 1, 2026 17:11
@github-actions github-actions Bot requested a review from eriknordmark April 1, 2026 17:33
@rucoder
Copy link
Copy Markdown
Contributor

rucoder commented Apr 2, 2026

@christoph-zededa why don't we use .dockerignore ?

@christoph-zededa
Copy link
Copy Markdown
Contributor Author

@christoph-zededa why don't we use .dockerignore ?

I want it to be visible f.e. when somebody looks up how it is done or copies some lines.

@christoph-zededa christoph-zededa added the side-quest A worthy adventure, but not essential for victory. Tackle when the main quest is safe! label Apr 13, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 13, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 29.87%. Comparing base (2281599) to head (c08bd97).
⚠️ Report is 518 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff             @@
##           master    #5732       +/-   ##
===========================================
+ Coverage   19.52%   29.87%   +10.34%     
===========================================
  Files          19       18        -1     
  Lines        3021     2417      -604     
===========================================
+ Hits          590      722      +132     
+ Misses       2310     1549      -761     
- Partials      121      146       +25     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@christoph-zededa christoph-zededa marked this pull request as ready for review April 14, 2026 10:12
@rene
Copy link
Copy Markdown
Contributor

rene commented Apr 16, 2026

@christoph-zededa you need to at least add the exception for Yetus.... since the

@christoph-zededa why don't we use .dockerignore ?

I want it to be visible f.e. when somebody looks up how it is done or copies some lines.

The problem is that by doing that you are introducing more parser errors to hadolint (--exclude is not recognized, like the --keep-git-dir), unfortunately these cannot be ignored with # hadolint... comment.... I agree is better for visibility, but I'd like to avoid introduce more Yetus errors, so put in the .dockerignore sounds better for now....

Add a .dockerignore file with Dockerfile to each package that uses
COPY . in its Dockerfile. This prevents the Dockerfile itself from
being copied into the image, so the docker hashes bumper does not
have to run several times anymore.

pkg/installer already had a .dockerignore covering this case.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Christoph Ostarek <christoph@zededa.com>
@christoph-zededa
Copy link
Copy Markdown
Contributor Author

/rerun red

@rene rene merged commit 0340762 into lf-edge:master Apr 20, 2026
40 of 47 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

side-quest A worthy adventure, but not essential for victory. Tackle when the main quest is safe!

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants