#Does Container.WithDirectory("", Container.Directory("")) allocate two copies of the files on disk?
1 messages · Page 1 of 1 (latest)
Yes I believe so. But might be worth double-checking given the size
Given your lack of confidence, is it correct to assume this is an implementation detail of BuildKit?
I was also wondering if applying include/exclude filters change the answer. Docker certainly doesn't seem to dedupe things at the file level, but rather does so at the layer level.
well I'm not a core engine dev hence my lack of confidence 😁 but yes it's a buildkit implem detail.
I'm at 99% confidence
@desert bone it will depend on some caveats on the WithDirectory call . More info about that in this discussion: https://github.com/dagger/dagger/discussions/9345#discussioncomment-11788963
The summary is that Dagger will try to use MergeOp when possible which will in consequence re-use the same underlying fs references when calling WithDirectory. However, there are cases where MergeOp can't be used (more info in the link above) and that will generate a duplication of the data
Thanks, this is very useful. Claude claims that BuildKit de-duplicates at the file level, but I can't find any supporting documentation for that on the internet.
if input.DestFileName == "" && input.SrcFileName != "" {
input.DestFileName = input.SrcFileName
}
Sweet Jesus, I could have been doing WithFile("foo/", other.File("bar")) instead of WithFile("foo/bar", other.File("bar")) this whole time.