Skip to content

Commit

Permalink
Skip whole dir dockerignoring with warning
Browse files Browse the repository at this point in the history
Fixes #7093
Docker-DCO-1.1-Signed-off-by: Alexandr Morozov <lk4d4math@gmail.com> (github: LK4D4)
  • Loading branch information
LK4D4 committed Jul 18, 2014
1 parent c116601 commit 7d97a5f
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
4 changes: 4 additions & 0 deletions archive/archive.go
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,10 @@ func TarWithOptions(srcPath string, options *TarOptions) (io.ReadCloser, error)
return err
}
if matched {
if filepath.Clean(relFilePath) == "." {
utils.Errorf("Can't exclude whole path, excluding pattern: %s", exclude)
continue
}
utils.Debugf("Skipping excluded path: %s", relFilePath)
if f.IsDir() {
return filepath.SkipDir
Expand Down
23 changes: 23 additions & 0 deletions integration-cli/docker_cli_build_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1565,6 +1565,29 @@ func TestDockerignoringDockerfile(t *testing.T) {
logDone("build - test .dockerignore of Dockerfile")
}

func TestDockerignoringWholeDir(t *testing.T) {
name := "testbuilddockerignorewholedir"
defer deleteImages(name)
dockerfile := `
FROM busybox
COPY . /
RUN [[ ! -e /.gitignore ]]
RUN [[ -f /Makefile ]]`
ctx, err := fakeContext(dockerfile, map[string]string{
"Dockerfile": "FROM scratch",
"Makefile": "all:",
".dockerignore": ".*\n",
})
defer ctx.Close()
if err != nil {
t.Fatal(err)
}
if _, err = buildImageFromContext(name, ctx, true); err != nil {
t.Fatal(err)
}
logDone("build - test .dockerignore whole dir with .*")
}

func TestBuildLineBreak(t *testing.T) {
name := "testbuildlinebreak"
defer deleteImages(name)
Expand Down

0 comments on commit 7d97a5f

Please sign in to comment.