buildah icon indicating copy to clipboard operation
buildah copied to clipboard

Add --parents option for COPY in Dockerfiles

Open uckelman opened this issue 1 year ago • 5 comments

Description

Docker added a --parents option to the Dockerfile COPY command last year:

https://github.com/moby/moby/issues/35639 https://github.com/moby/buildkit/pull/3001 https://docs.docker.com/reference/dockerfile/#copy---parents

buildah doesn't know how to handle COPY --parents so errors out on Dockerfiles which use it.

I'm seeing increasing use of --parents in Dockerfiles I have to deal with, which is making it hard to use podman/buildah instead of Docker. --parents is also a genuinely useful option on its own, so would be nice to have not just for compatibility.

It's quite useful to be able to do things like

COPY --parents src/**/pyproject.toml src/**/poetry.lock /app/

and maintain the directory structure in the destination without having to list out every single file.

uckelman avatar May 31 '24 13:05 uckelman

I believe @mheon is either working on this or looking into this. Matt?

TomSweeneyRedHat avatar Jun 05 '24 00:06 TomSweeneyRedHat

Yep, hoping to get to this over the next few weeks

mheon avatar Jun 05 '24 05:06 mheon

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

github-actions[bot] avatar Jul 06 '24 00:07 github-actions[bot]

This is so badly needed with Java projects that involve multiple pom.xml files. Any progress on this?

cyqsimon avatar Sep 12 '24 08:09 cyqsimon

any more update?

krmao avatar Oct 10 '24 10:10 krmao

bump this is a good idea

jorlando-elucid avatar Dec 24 '24 03:12 jorlando-elucid

any news? :)

Peneheals avatar Jan 02 '25 13:01 Peneheals

Could you give me a sample Containerfile that would use this?

rhatdan avatar Jan 06 '25 20:01 rhatdan

@rhatdan Of course. This sort of thing is useful in a workspace of any language where nested manifest files are involved.

Here is an example in Rust (they are working on toolchain support for building only dependencies without project source, but that's not our concern).

Alternatively, here is an example with Maven (which has existing toolchain support). To optimise layer caching, you would want something like this:

COPY --parents **/pom.xml ./
RUN mvn dependency:go-offline

Without --parents, you'd have to manually path to every sub-manifest.

cyqsimon avatar Jan 07 '25 03:01 cyqsimon

https://github.com/larixer/docker-js-monorepo has some pretty good examples as well.

oliversalzburg avatar Jan 07 '25 10:01 oliversalzburg

Any news on this? it would be really helpful to have --parents supported

kikorb avatar Jan 31 '25 15:01 kikorb

@Honny1 might have time to work on this?

mheon avatar Jan 31 '25 17:01 mheon

I will take a look.

Honny1 avatar Feb 05 '25 09:02 Honny1