-
Notifications
You must be signed in to change notification settings - Fork 11
integrate frontend/dockerfile/dockerignore from BuildKit #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Signed-off-by: Tibor Vass <tibor@docker.com>
filepath.Clean converts filenames to filenames with native path separators. Use ToSlash to normalize. Signed-off-by: Anusha Ragunathan <anusha@docker.com>
This fix tries to address the issue raised in #20083 where comment is not supported in `.dockerignore`. This fix updated the processing of `.dockerignore` so that any lines starting with `#` are ignored, which is similiar to the behavior of `.gitignore`. Related documentation has been updated. Additional tests have been added to cover the changes. This fix fixes #20083. Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
This fix tries to address issues related to #23221 where Dockerignore may consists of UTF-8 BOM. This likely happens when Notepad tries to save a file as UTF-8 in Windows. This fix skips the UTF-8 BOM bytes from the beginning of the Dockerignore if exists. Additional tests has been added to cover the changes in this fix. This fix is related to #23221 (UTF-8 BOM in Dockerfile). Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
Signed-off-by: allencloud <allen.sun@daocloud.io>
…matting text does not appear to contain a placeholder Signed-off-by: Helen Xie <chenjg@harmonycloud.cn>
According to documentation (https://docs.docker.com/engine/reference/builder/#dockerignore-file), absolute paths like `/foo/bar` should have the same effect as `foo/bar`. This is not the case today. This fix normalize paths when reading the .dockerignore file by removing leading slashes. Signed-off-by: Simon Ferquel <simon.ferquel@docker.com>
Signed-off-by: Daniel Nephin <dnephin@docker.com>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Signed-off-by: David Gageot <david.gageot@doctolib.com>
Enable gosimple linter
…ile-ref Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit replaces `os.MkdirTemp` with `t.TempDir` in tests. The
directory created by `t.TempDir` is automatically removed when the test
and all its subtests complete.
Prior to this commit, temporary directory created using `os.MkdirTemp`
needs to be removed manually by calling `os.RemoveAll`, which is omitted
in some tests. The error handling boilerplate e.g.
defer func() {
if err := os.RemoveAll(dir); err != nil {
t.Fatal(err)
}
}
is also tedious, but `t.TempDir` handles this for us nicely.
Reference: https://pkg.go.dev/testing#T.TempDir
Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
Required for gosec Signed-off-by: Justin Chadwell <me@jedevc.com>
Signed-off-by: Justin Chadwell <me@jedevc.com>
- don't use a temp-file for the test as all we need is a reader - use a const and string-literal for the test-content, which makes it slightly more readable - don't use hard-coded tests for each line, but use an "expected" slice - don't fail early if line-numbers don't match Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Use "doc links" where possible, and better describe the function. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
While this function would usually be used for read a `.dockerignore` file,
it accepts a Reader and can also be used to handle ignore patterns from
other files (e.g. `Dockerfile.dockerignore`) or other sources. The error
was also wrapped multiple times in some code-paths, which could lead to
an error being formatted as:
failed to parse dockerignore: error reading .dockerignore: <some error>
Let's remove mention of the `.dockerignore` filename from the error, and
leave it to the caller to include the filename.
This patch also brings the MainContext dockerignore error inline with the
NamedContext dockerignore error, now printing the exact name of the file.
Co-authored-by: Justin Chadwell <me@jedevc.com>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
47300f2 to
9736100
Compare
Integrating the "frontend/dockerfile/dockerignore" package from
github.com/moby/buildkit at commit 9da03ce42beb47d0d0a34c68ea90cac793b79851
Steps taken:
# install filter-repo (https://github.com/newren/git-filter-repo/blob/main/INSTALL.md)
brew install git-filter-repo
# create a temporary clone of docker
cd ~/Projects
git clone https://github.com/moby/buildkit.git buildkit_temp
cd buildkit_temp
# commit taken from
git rev-parse --verify HEAD
9da03ce42beb47d0d0a34c68ea90cac793b79851
# remove all code, except for 'frontend/dockerfile/dockerignore', and rename to /ignorefile
git filter-repo \
--path-match 'frontend/dockerfile/dockerignore/' \
--path-rename frontend/dockerfile/dockerignore/dockerignore.go:ignorefile/ignorefile.go \
--path-rename frontend/dockerfile/dockerignore/dockerignore_test.go:ignorefile/ignorefile_test.go
# go to the target github.com/moby/patternmatcher repository
cd ~/go/src/github.com/moby/patternmatcher
# create a branch to work with
git checkout -b integrate_dockerignore
# add the temporary repository as an upstream and make sure it's up-to-date
git remote add buildkit_temp ~/Projects/buildkit_temp
git fetch buildkit_temp
# merge the upstream code
git merge --allow-unrelated-histories --signoff -S buildkit_temp/master
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
9736100 to
36a4227
Compare
tonistiigi
approved these changes
Aug 22, 2023
Member
Author
|
Thanks! I'll bring this one in 👍 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Integrating the "frontend/dockerfile/dockerignore" package from
github.com/moby/buildkit at commit moby/buildkit@9da03ce
Steps taken: