imgutil
imgutil copied to clipboard
Preserve layer metadata of base image
When using the pack build
command, the layer metadata of the run base image is not preserved and cleared out.
To reproduce, you can take the samples repository: https://github.com/buildpacks/samples
Let's run the following command as described in the "Build for ARM architecture" tutorial:
pack build java-maven-sample --path samples/apps/java-maven/ --builder heroku/builder:24 y
After the build, look at the history of the built image:
> docker history java-maven-sample
IMAGE CREATED CREATED BY SIZE COMMENT
7aaa72af6982 N/A Buildpacks Process Types 23B
<missing> N/A Buildpacks Launcher Config 488B
<missing> N/A Buildpacks Application Launcher 2.56MB
<missing> N/A Application Layer 18.6MB
<missing> N/A Software Bill-of-Materials 35.1kB
<missing> N/A Layer: 'runtime', Created by buildpack: hero… 2.42MB
<missing> N/A Layer: 'openjdk', Created by buildpack: hero… 223MB
<missing> N/A 311MB
<missing> N/A 101MB
As you can see, the last two layers (layers coming from the run base image) don't contain any "CREATED BY" or "COMMENT" information anymore.
It would be valuable to preserve the information in order to identify the commands used to build the layer during debugging.
The base image itself (heroku/heroku:24
) contains the metadata information. The two relevant layers can be identified via the size (311MB and 101MB).
> docker history heroku/heroku
IMAGE CREATED CREATED BY SIZE COMMENT
a35bef8f087d 43 hours ago LABEL io.buildpacks.stack.id=heroku-24 0B buildkit.dockerfile.v0
<missing> 43 hours ago LABEL io.buildpacks.base.maintainer=Heroku 0B buildkit.dockerfile.v0
<missing> 43 hours ago LABEL io.buildpacks.base.homepage=https://gi… 0B buildkit.dockerfile.v0
<missing> 43 hours ago LABEL io.buildpacks.base.distro.version=24.04 0B buildkit.dockerfile.v0
<missing> 43 hours ago LABEL io.buildpacks.base.distro.name=ubuntu 0B buildkit.dockerfile.v0
<missing> 43 hours ago USER heroku 0B buildkit.dockerfile.v0
<missing> 43 hours ago RUN /bin/sh -c /build/setup.sh # buildkit 311MB buildkit.dockerfile.v0
<missing> 3 weeks ago /bin/sh -c #(nop) CMD ["/bin/bash"] 0B
<missing> 3 weeks ago /bin/sh -c #(nop) ADD file:9018302bda8cbdb55… 101MB
<missing> 3 weeks ago /bin/sh -c #(nop) LABEL org.opencontainers.… 0B
<missing> 3 weeks ago /bin/sh -c #(nop) LABEL org.opencontainers.… 0B
<missing> 3 weeks ago /bin/sh -c #(nop) ARG LAUNCHPAD_BUILD_ARCH 0B
<missing> 3 weeks ago /bin/sh -c #(nop) ARG RELEASE 0B