diff --git a/client/llb/fileop.go b/client/llb/fileop.go index 831c4f381edd7..e054f128b1fc1 100644 --- a/client/llb/fileop.go +++ b/client/llb/fileop.go @@ -801,6 +801,7 @@ func (f *FileOp) Marshal(ctx context.Context, c *Constraints) (digest.Digest, [] func normalizePath(parent, p string, keepSlash bool) string { origPath := p + // first, normalize everything to unix path p = path.Clean(p) if !path.IsAbs(p) { p = path.Join("/", parent, p) diff --git a/frontend/dockerfile/dockerfile2llb/convert.go b/frontend/dockerfile/dockerfile2llb/convert.go index ea5e8601536ba..e11da2eb69ebc 100644 --- a/frontend/dockerfile/dockerfile2llb/convert.go +++ b/frontend/dockerfile/dockerfile2llb/convert.go @@ -1139,7 +1139,10 @@ func dispatchCopy(d *dispatchState, cfg copyConfig) error { } if cfg.params.DestPath == "." || cfg.params.DestPath == "" || cfg.params.DestPath[len(cfg.params.DestPath)-1] == filepath.Separator { - dest += string(filepath.Separator) + // can use unix path separator since + // at this point, Windows dest path is already normalized + // in `pathRelativeToWorkingDir` above. + dest += "/" } var copyOpt []llb.CopyOption diff --git a/solver/llbsolver/file/backend.go b/solver/llbsolver/file/backend.go index 293caa1082bd9..58b489cb8a286 100644 --- a/solver/llbsolver/file/backend.go +++ b/solver/llbsolver/file/backend.go @@ -139,7 +139,7 @@ func docopy(ctx context.Context, src, dest string, action pb.FileActionCopy, u * } destPath, err := cleanPath(action.Dest) if err != nil { - return errors.Wrap(err, "cleaning path") + return errors.Wrap(err, "cleaning destination path") } if !action.CreateDestPath { p, err := fs.RootPath(dest, filepath.Join("/", action.Dest))