containers / buildah

A tool that facilitates building OCI images.
https://buildah.io
Apache License 2.0
7.4k stars 781 forks source link

[RFE] Add support for `--link` in `COPY/ADD` #4325

Open lucacome opened 2 years ago

lucacome commented 2 years ago

Description

Buildkit added support for the --link flag. Quoting from the docs:

Enabling this flag in COPY or ADD commands allows you to copy files with enhanced semantics where your files remain independent on their own layer and don't get invalidated when commands on previous layers are changed.

When --link is used your source files are copied into an empty destination directory. That directory is turned into a layer that is linked on top of your previous state.

This is a feature request to add this feature in buildah šŸ™‚

CypherpunkSamurai commented 2 years ago

Hello @lucacome and @TomSweeneyRedHat,

I want to contribute to this issue but am new to the project, How can I get started? :)

rhatdan commented 2 years ago

Well first you would need to add support for --link in https://github.com/openshift/imagebuilder I believe. @flouthoc Could you help @CypherpunkSamurai contribute.

flouthoc commented 2 years ago

Hi,

Yes implementation must start from imagebuilder and introduce a new attribute link bool to Copy struct and must be set true when COPY or ADD contains --link and on buildah side if Copy.link == truethen layer must be created on a scratch base, in theory COPY --link must be replaced with a functionality similar to stage where scratch image is base and file is just copied to target path.

COPY --link /src /target

must create a intermediate image equivalent to

FROM scatch
COPY /src /target
lucacome commented 1 year ago

Hi @CypherpunkSamurai

I was wondering if you've had a chance to start working on this? Or do you need any help? šŸ™‚

CypherpunkSamurai commented 1 year ago

Really sorry about this, I had gotten a little busy with college work.

I'll start work asap by this Saturday.

rhatdan commented 1 year ago

No problem college work should come first.

CypherpunkSamurai commented 1 year ago

Hello everyone, really sorry again for stalling this issue.

Ok Here's what I understand from the documentation of the --link tag for COPY and ADD build commands:

Here's how I understand how I need to implement it:

Please check if this is correct

flouthoc commented 1 year ago

Yes SGTM. Pretty much what's written here https://github.com/containers/buildah/issues/4325#issuecomment-1286568410 but I'd suggest if you have time to take a look and play with buildkit a bit before implementing this. My explanation in above comment is more conceptual and in past we have seen that buildkit's feature is not completely described in the documentation so its worth verifying edge cases before implementing this.

Note: Buildah mostly tries to match parity with buildkit as much as possible.

CypherpunkSamurai commented 1 year ago

Sure. I need to try both the tools first i guess. Would be interesting. I'll try my best to help this issue :)

github-actions[bot] commented 1 year ago

A friendly reminder that this issue had no activity for 30 days.

CypherpunkSamurai commented 1 year ago

Alright I researched quite a bit about rootfs and build root for the few weeks. I feel comfortable with linux rootfs and how it works.

Um, if you don't mind guys (@flouthoc and @rhatdan) can you please help me point out how buildah handles creating scratch rootfs? (in addition line number would be very cool)

flouthoc commented 1 year ago

@CypherpunkSamurai Its hard to pin the exact line since I'll have to skim the code but I can tell that builder creates a container for FROM scratch instruction you can actually find the part where builder actually creates container.

github-actions[bot] commented 1 year ago

A friendly reminder that this issue had no activity for 30 days.

rhatdan commented 1 year ago

Since we have not heard any more feedback, closing. Reopen if you want to continue looking into this one.

lucacome commented 1 year ago

@rhatdan I'm still interested in this and I'd like to keep it open. Maybe somebody else can take over from @CypherpunkSamurai ?

flouthoc commented 1 year ago

@CypherpunkSamurai If you are running short on time, I'd request to assign this issue to me :)

CypherpunkSamurai commented 1 year ago

Sure. I'm having my exams right now, probably not a great time to work on this. I better not keep this issue stalling :)

On 24 January 2023 10:18:08 AM flouthoc @.***> wrote:

@CypherpunkSamurai If you are running short on time, I'd request to assign this issue to me :) ā€” Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>

github-actions[bot] commented 1 year ago

A friendly reminder that this issue had no activity for 30 days.

der-eismann commented 1 year ago

Hey @flouthoc, any updates on this? This feature would be great to have :slightly_smiling_face:

veritas9872 commented 1 year ago

I am also very interested.

github-actions[bot] commented 1 year ago

A friendly reminder that this issue had no activity for 30 days.

sanmai-NL commented 1 year ago

Not stale.

lucacome commented 1 year ago

Any updates on this?

buildkit states concurrent, cache-efficient, and Dockerfile-agnostic builder toolkit so I was also wondering why podman is not using buildkit instead of buildah.

It seems like a lot of work to try and keep parity with buildkit and that effort could be put into improving buildkit? šŸ¤·ā€ā™‚ļø

rhatdan commented 1 year ago

@flouthoc This is rising in importance since Podman-desktop needs this.

BlaineEXE commented 11 months ago

Ditto, want this functionality

johnlauder commented 11 months ago

Bump, would like this functionality. Currently have to modify Dockerfiles to work with podman due to this issue.

sastorsl commented 11 months ago

@CypherpunkSamurai did you have any work done on this you could share, even if incomplete? I could try and contribute, and if I'm not able - some ground work could be of guidance.

sigbits commented 7 months ago

I gave it a try and switched from docker to podman, but without COPY --link it's useless for my projects. Since the issue is already pretty old: is there any chance this will be fixed any time in the near future?

huww98 commented 7 months ago

Iā€™m currently running buildkitd in podman, then use buildctl to build images.

danishprakash commented 6 months ago

@flouthoc If you haven't started, I can take a shot at this.

rhatdan commented 5 months ago

@danishprakash go for it. @flouthoc has gone back to school and has much less time to work on this.

edwbuck commented 4 months ago

Any updates on this one?

apollo13 commented 2 months ago

I'd love to see this as well. But I am kinda wondering if it makes sense to reimplement what buildkit does instead of using/embedding buildkit in podman? FWIW, aside from being daemonless (though you kind of can run buildkit like that as well: https://github.com/moby/buildkit?tab=readme-ov-file#daemonless ) podman build imo no longer has any features over docker build(x). The performance gains with buildkits are so big that I am currently reworking a few of our internal pipelines to use buildkit.

flouthoc commented 2 months ago

But I am kinda wondering if it makes sense to reimplement what buildkit does instead of using/embedding buildkit in podman?

@apollo13 Could you please elaborate on this, podman does not uses or embed buildkit as-is most of the features are implemented in buildah as per buildah's design and podman uses buildah not buildkit.

apollo13 commented 2 months ago

@flouthoc I was mainly wondering if it makes sense (or were possible) for podman to directly use buildkit instead of buildah. This would allow keeping feature parity more easily and also pick up all performance improvements. Especially with multi stage builds podman is really really much slower since buildkit is able to parallelize many things (unless I missed a flag for podman build)

flouthoc commented 2 months ago

Podman multi-stage build is parallel but you have to use --jobs flag. See https://docs.podman.io/en/latest/markdown/podman-build.1.html#jobs-number

apollo13 commented 2 months ago

Oh thank you, how did I miss that (is it new?). That does indeed help for multi-stage builds. Can you recommend any other knobs to tune?

On Sun, Aug 18, 2024, at 22:17, flouthoc wrote:

Podman multi-stage build is parallel but you have to use --jobs flag. See https://docs.podman.io/en/latest/markdown/podman-build.1.html#jobs-number

ā€” Reply to this email directly, view it on GitHub https://github.com/containers/buildah/issues/4325#issuecomment-2295378163, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAT5C7QBYVLOL3FLASV2D3ZSD6OBAVCNFSM6AAAAAAQ72EQZOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEOJVGM3TQMJWGM. You are receiving this because you were mentioned.Message ID: @.***>