-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Description
Follow-up docker/buildx#746 (comment)
In some cases it can be useful to cleanup destination directory while using the local exporter. Let's say I want to vendor my project and copy back to the client, the local exporter will copy the files directly to the client and some of them may have been deleted but will still be there client side.
To work around we have to rely on scripting that will export to a temporary folder, then prune the vendor folder and move back from temp to the vendor directory. This is painful and should be handled directly by BuildKit.
I suggest that we add a mode attribute to the local exporter handled by filesync.CopyToCaller:
buildkit/exporter/local/export.go
Lines 123 to 125 in c2f909e
| if err := filesync.CopyToCaller(ctx, fs, caller, progress); err != nil { | |
| return err | |
| } |
I see three possible options today:
-o type=local,dest=path/to/output-dir,mode=copy: current behavior-o type=local,dest=path/to/output-dir,mode=mirror: delete dest files/folders that no longer exist in source-o type=local,dest=path/to/output-dir,mode=backup: backup files that may already exist in dest,.~<numbered>~will be the suffix. Each backup file will have a version number added to the filename. e.g.path/to/output-dir/myfile.txt.~1~. Pretty much likecp --backup=numbered
Might need some changes upstream on https://github.com/tonistiigi/fsutil