(This is a precursor to a full EP on the topic, to get ideas out and start discussion)
In a "rebase" operation, an original image's base image layers are swapped out with another set of layers from another image.
Users might want to do this for a couple reasons:
- if a vulnerability is found in a base image, you can replace those layers in an application image simply using registry API operations, and not have to rebuild the image from scratch on top of the new image. This can be especially useful if you need to quickly produce lots of images where the vulnerability is fixed, or if you no longer have access to the original source.
- if you'd prefer to have another image as the base image; for example, an image is built on a large-ish image, and you'd prefer to have it based on a slimmer image like
ubi or openjdk-slim, etc.
(the second case, producing slimmer built images, seems to be a motivating use case for runtime config)
In either case, rebasing is not guaranteed to be safe by default, and care must be taken when building to ensure your application code can handle being rebased onto other base images. Rebasing onto a base image with different versions of system libraries or installed runtimes might produce an image that can't execute. Rebased images should still be subjected to tests before being deployed to production. Buildpacks for example takes care to separate application layers from base image layers, so that rebasing is more likely to be successful.
To enable rebasing in Shipwright, we could define a new rebase BuildStrategy, which would expect an input image, and parameters for old- and new-base images (or could expect this to be stored in OCI image annotations on the image), and an output of where to publish the newly rebased image. (As an alternative, we could define a new Rebase CRD alongside Build, since they're fairly separate operations, I'm not sure that's necessary though, and a BuildStrategy is easier to iterate on)
When BuildRuns are triggered, rebasing builds could watch for updates to a base image and automatically produce rebased images built on that new base image.
References:
cc @sbose78
(This is a precursor to a full EP on the topic, to get ideas out and start discussion)
In a "rebase" operation, an original image's base image layers are swapped out with another set of layers from another image.
Users might want to do this for a couple reasons:
ubioropenjdk-slim, etc.(the second case, producing slimmer built images, seems to be a motivating use case for
runtimeconfig)In either case, rebasing is not guaranteed to be safe by default, and care must be taken when building to ensure your application code can handle being rebased onto other base images. Rebasing onto a base image with different versions of system libraries or installed runtimes might produce an image that can't execute. Rebased images should still be subjected to tests before being deployed to production. Buildpacks for example takes care to separate application layers from base image layers, so that rebasing is more likely to be successful.
To enable rebasing in Shipwright, we could define a new
rebaseBuildStrategy, which would expect an input image, and parameters for old- and new-base images (or could expect this to be stored in OCI image annotations on the image), and anoutputof where to publish the newly rebased image. (As an alternative, we could define a newRebaseCRD alongsideBuild, since they're fairly separate operations, I'm not sure that's necessary though, and a BuildStrategy is easier to iterate on)When BuildRuns are triggered, rebasing builds could watch for updates to a base image and automatically produce rebased images built on that new base image.
References:
crane rebasedocumentationcc @sbose78