Merge pull request #3762 from thaJeztah/no_CanonicalTarNameForPath

build: replace uses of archive.CanonicalTarNameForPath
This commit is contained in:
Sebastiaan van Stijn 2022-09-01 22:22:45 +02:00 committed by GitHub
commit 52b89d7668
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 1 deletions

View File

@ -265,7 +265,7 @@ func runBuild(dockerCli command.Cli, options buildOptions) error {
}
// And canonicalize dockerfile name to a platform-independent one
relDockerfile = archive.CanonicalTarNameForPath(relDockerfile)
relDockerfile = filepath.ToSlash(relDockerfile)
excludes = build.TrimBuildFilesFromExcludes(excludes, relDockerfile, options.dockerfileFromStdin())
buildCtx, err = archive.TarWithOptions(contextDir, &archive.TarOptions{

View File

@ -32,6 +32,9 @@ func TrimBuildFilesFromExcludes(excludes []string, dockerfile string, dockerfile
if keep, _ := fileutils.Matches(".dockerignore", excludes); keep {
excludes = append(excludes, "!.dockerignore")
}
// canonicalize dockerfile name to be platform-independent.
dockerfile = filepath.ToSlash(dockerfile)
if keep, _ := fileutils.Matches(dockerfile, excludes); keep && !dockerfileFromStdin {
excludes = append(excludes, "!"+dockerfile)
}