Question: Can we extract/unpack the new layers added to an image except the parent ?
Question: Can we extract/unpack the new layers added to an image except the parent ?
Why such a question ? For the buildpacks CNCF project we are investigating a way to extend the following application - Lifecycle in order during a build to perform the following steps:
- Execute a Dockerfiles top of an image to add new packages, ... (see: https://github.com/redhat-buildpacks/poc/blob/main/bud/bud.go#L40). A new image is created locally and is available under the graph folder path (vfs, overlay, ...)
- Find the newly created layers (without the parent)
- Extract the content of the new layers created to a volume mounted (e.g /extracted)
- The content extracted will be next used by the lifecycle application to build an image for a runtime (Java spring boot, quarkus). As some needed tools are not packaged with the builder image, they will then become available from the
/extractedvolume mounted
Use umoci as lib
As we plan to use umoci from the lifecycle application, I'm wondering if it could be reused as a go lib module ?
This is not really doable with the umoci CLI at the moment, but (to answer your second question) you can use umoci as a library (https://github.com/cisco/stacker uses it for instance) and as a library you could call the individual layer extraction functions for each layer yourself.
Though it should be noted that umoci's library APIs are still technically unstable until 1.0 (though in practice I try not to make breaking changes, and any such changes are mentioned in the changelog).
This is not really doable with the umoci CLI at the moment, but (to answer your second question) you can use umoci as a library (https://github.com/cisco/stacker uses it for instance) and as a library you could call the individual layer extraction functions for each layer yourself.
Many thanks for the information. I will have a look. BTW, the github project (cisco/stacker) reported is not publicly available
My bad, it's not in the cisco organisation. https://github.com/anuvu/stacker is the right repo.