Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MERGE statement for targets #3976

Open
hidmic opened this issue Apr 3, 2024 · 1 comment
Open

MERGE statement for targets #3976

hidmic opened this issue Apr 3, 2024 · 1 comment
Labels
type:proposal A proposal for a new feature

Comments

@hidmic
Copy link

hidmic commented Apr 3, 2024

Use case

Spiritually related to #2480. Earthly is amazing as it is but building interdependent software packages is still somewhat painful. To the best of my knowledge, when you have a complex target DAG you are forced to either:

  1. linearize your DAG, which sacrifices modularity and breaks down when the thing doesn't look like a tree
  2. craft COPY statements to pull the necessary artifacts from each dependency, which is brittle when you don't have total control over the layer content
  3. have a function that implements each target so you can chain them freely through invocation, which requires some care with build contexts (and still gets messy when function+target pairs are split across local and remote Earthfiles using COPYs)

Even if functions were meant to be the escape hatch, I believe first-class support for complex target DAGs would be a great feature. And since Buildkit supports merge and diff operations already, I imagine a MERGE statement for targets wouldn't be far fetched.

Note: In all honesty, this isn't as much of a proposal as it is a question. I see COPYs are merged copies (à la COPY --link), so I imagine this crossed your mind already and for some reason you discarded it. I wonder why.

Expected Behavior

  1. Given the following Earthfile:

    VERSION 0.8
    
    foo:
        RUN apt-get update && apt-get install -y foo
    
    bar:
        RUN apt-get update && apt-get install -y bar
    
    baz:
        MERGE +foo +bar
        SAVE IMAGE baz:latest
  2. Run earthly +baz.

  3. Confirm that baz:latest history shows both foo and bar.

MERGE could be a single llb.Merge operation or recursively expand to compute merge-diffs by interleaving llb.Diff and llb.Merge operations.

@hidmic hidmic added the type:proposal A proposal for a new feature label Apr 3, 2024
@hidmic
Copy link
Author

hidmic commented Apr 11, 2024

Hmm, looks like this didn't draw much attention 😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:proposal A proposal for a new feature
Projects
Status: No status
Development

No branches or pull requests

1 participant