diff options
author | Daniel J Walsh <dwalsh@redhat.com> | 2021-07-12 15:57:16 -0400 |
---|---|---|
committer | Daniel J Walsh <dwalsh@redhat.com> | 2021-07-14 20:22:51 -0400 |
commit | c9970647ba6338aeb29c1bd82d8f22f33b1880b9 (patch) | |
tree | 2b05f930ad17f8aba5450bd838923d011195b7b5 /pkg/bindings/images | |
parent | 1e236845e631d6f7596f6bd094d55f58b8156e06 (diff) | |
download | podman-c9970647ba6338aeb29c1bd82d8f22f33b1880b9.tar.gz podman-c9970647ba6338aeb29c1bd82d8f22f33b1880b9.tar.bz2 podman-c9970647ba6338aeb29c1bd82d8f22f33b1880b9.zip |
podman-remote build use .containerignore over .dockerignore
$ mkdir zzz;cd zzz
$ printf "FROM quay.io/libpod/testimage:20210610\nCOPY ./ ./\nCOPY subdir ./\n" >Dockerfile
$ printf "*\nsubdir\n\!*/sub1*\n" >.dockerignore
$ mkdir subdir; touch subdir/sub1.txt
$ ../bin/podman-remote build .
Should fail, but succeeds because we are not sending over the
.dockerignore file to the server side. This PR will send the
.dockerignore so the server side and use it.
Fixes: #10907
Also if both .containerignore and .dockerignore in the context
directory, podman-remote should prefer .containerignore and not use
.dockerignore.
Fixes: #10908
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
Diffstat (limited to 'pkg/bindings/images')
-rw-r--r-- | pkg/bindings/images/build.go | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/pkg/bindings/images/build.go b/pkg/bindings/images/build.go index 3fbc41f99..142204f27 100644 --- a/pkg/bindings/images/build.go +++ b/pkg/bindings/images/build.go @@ -302,7 +302,7 @@ func Build(ctx context.Context, containerFiles []string, options entities.BuildO tarContent := []string{options.ContextDirectory} newContainerFiles := []string{} - dontexcludes := []string{"!Dockerfile", "!Containerfile"} + dontexcludes := []string{"!Dockerfile", "!Containerfile", "!.dockerignore", "!.containerignore"} for _, c := range containerFiles { if c == "/dev/stdin" { content, err := ioutil.ReadAll(os.Stdin) @@ -550,9 +550,13 @@ func nTar(excludes []string, sources ...string) (io.ReadCloser, error) { } func parseDockerignore(root string) ([]string, error) { - ignore, err := ioutil.ReadFile(filepath.Join(root, ".dockerignore")) - if err != nil && !os.IsNotExist(err) { - return nil, errors.Wrapf(err, "error reading .dockerignore: '%s'", root) + ignore, err := ioutil.ReadFile(filepath.Join(root, ".containerignore")) + if err != nil { + var dockerIgnoreErr error + ignore, dockerIgnoreErr = ioutil.ReadFile(filepath.Join(root, ".dockerignore")) + if dockerIgnoreErr != nil && !os.IsNotExist(dockerIgnoreErr) { + return nil, errors.Wrapf(err, "error reading .containerignore: '%s'", root) + } } rawexcludes := strings.Split(string(ignore), "\n") excludes := make([]string, 0, len(rawexcludes)) |