dockerfile: add new context subrequest
Fixes https://github.com/moby/buildkit/issues/1181.
Opening as a draft to get some early feedback on the approach.
This PR adds a new context subrequest to the dockerfile frontend that allows inspecting the files that would be transferred for a build.
To actually get details of the files in the context, we hack fsutil (I can open an upstream PR if this approach seems good) to support a new Truncate option. If Truncate is set, then we only get the file stat details, and don't actually request the file from the client, instead calling truncate on the file to get it to the right size (so we actually set all the file details except for the content) -- this file shouldn't be stored on disk, since on most file systems this will just create a sparse file.
Not entirely sure on the output format - at the moment, it just lists every file with their sizes, but it might be nice to group by directory and allow controlling the depth (similar to du).
I don't currently have time to get this one into a finished state (sorry!), so if someone wants to adopt this one, please do!
cc @cybercyst I think I started work on this based on something you suggested :smile: sorry I don't the time to do it!