Skip to content

Proposal: Add mode attribute to local exporter #2805

@crazy-max

Description

@crazy-max

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:

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 like cp --backup=numbered

Might need some changes upstream on https://github.com/tonistiigi/fsutil

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions