Skip to content

Conversation

@thaJeztah
Copy link
Member

Integrating the "frontend/dockerfile/dockerignore" package from
github.com/moby/buildkit at commit moby/buildkit@9da03ce

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

Tibor Vass and others added 21 commits December 14, 2015 14:59
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@gmail.com>
Signed-off-by: Daniel Nephin <dnephin@docker.com>
Signed-off-by: wingkwong <wingkwong.code@gmail.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>
…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>
@thaJeztah thaJeztah force-pushed the integrate_dockerignore branch from 47300f2 to 9736100 Compare July 30, 2023 10:37
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>
@thaJeztah
Copy link
Member Author

Thanks! I'll bring this one in 👍

@thaJeztah thaJeztah merged commit 347bb8d into moby:main Aug 22, 2023
@thaJeztah thaJeztah deleted the integrate_dockerignore branch August 22, 2023 20:52
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.