Skip to content

Ignore .containerignore for git repositories in ADD#6800

Open
simonbrauner wants to merge 1 commit intocontainers:mainfrom
simonbrauner:issue-6614
Open

Ignore .containerignore for git repositories in ADD#6800
simonbrauner wants to merge 1 commit intocontainers:mainfrom
simonbrauner:issue-6614

Conversation

@simonbrauner
Copy link
Copy Markdown

@simonbrauner simonbrauner commented Apr 21, 2026

What type of PR is this?

/kind api-change

/kind bug

/kind cleanup
/kind deprecation
/kind design
/kind documentation
/kind failing-test
/kind feature
/kind flake
/kind other

What this PR does / why we need it:

How to verify it

Which issue(s) this PR fixes:

Fixes: #6614

Special notes for your reviewer:

Does this PR introduce a user-facing change?

Local `.containerignore` is no longer applied to ADD from git repositories.

@simonbrauner simonbrauner force-pushed the issue-6614 branch 4 times, most recently from ac2f35b to 9ae4022 Compare April 22, 2026 14:51
@packit-as-a-service
Copy link
Copy Markdown

Ephemeral COPR build failed. @containers/packit-build please check.

1 similar comment
@packit-as-a-service
Copy link
Copy Markdown

Ephemeral COPR build failed. @containers/packit-build please check.

@simonbrauner simonbrauner marked this pull request as ready for review April 22, 2026 16:24
@dosubot dosubot Bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Apr 22, 2026
Comment thread docs/buildah-build.1.md Outdated
Copy link
Copy Markdown
Member

@Honny1 Honny1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, once @TomSweeneyRedHat 's comment is addressed.

Copy link
Copy Markdown
Member

@nalind nalind left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The stageExecutor.performCopy() method sets the "Excludes" field in the options and passes the list of sources to the Add() method. Can't it base the "Excludes" value it passes in on whether or not a source value it's also passing in is a git location?

If need be, the sourceIsGit() helper function could be moved from add.go to an internal package so that performCopy() could call it. There's a check early on in define.TempDirForURL() that could probably stand to use it, too.

Comment thread tests/bud.bats Outdated
Comment thread tests/bud.bats
mkdir -p $contextdir
cat > $contextdir/Dockerfile << _EOF
FROM busybox
ADD http://0.0.0.0:${HTTP_SERVER_PORT}/git/podman.git#v5.0.0 /podman-tag
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could the test -f that's being done below be done as a RUN instruction during the build?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it could, and it is simpler that way. Fixed.

Fixes: containers#6614

Signed-off-by: Šimon Brauner <sbrauner@redhat.com>
@simonbrauner
Copy link
Copy Markdown
Author

@nalind thanks for the review

The stageExecutor.performCopy() method sets the "Excludes" field in the options and passes the list of sources to the Add() method. Can't it base the "Excludes" value it passes in on whether or not a source value it's also passing in is a git location?

If need be, the sourceIsGit() helper function could be moved from add.go to an internal package so that performCopy() could call it. There's a check early on in define.TempDirForURL() that could probably stand to use it, too.

Can you elaborate on this? If I understand this correctly, the idea is to set excludes correctly based on what the source is instead of having two - excludes and gitExcludes, and deciding which one is used later. I am fine with moving sourceIsGit elsewhere so that I can use it in the function that calls Add(), but I am not sure how to use sourceIsGit afterwards.

Because with my understanding:

The Add() method goes through all the sources at once, so there could be both git and non-git sources, so I cannot have one excludes.

Unless:

  1. I call Add() for each source separately. Which seems like a strange idea, given that Add() is implemented to handle all the sources at once.
  2. I call Add() twice; once for git sources and once for non-git sources. Which could be problematic when ordering matters in case there is ADD local git local git /mount-dir.

@nalind
Copy link
Copy Markdown
Member

nalind commented May 6, 2026

2. I call `Add()` twice; once for git sources and once for non-git sources. Which could be problematic when ordering matters in case there is `ADD local git local git /mount-dir`.

That's what we more or less already do when heredocs are also in the mix, so that wouldn't be a new problem.

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

Labels

size:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

.dockerignore removes files from ADD git source

4 participants