msv-lab / modus

A language for building Docker/OCI container images
GNU Affero General Public License v3.0
279 stars 9 forks source link

Support from("scratch") #157

Closed maowtm closed 2 years ago

maowtm commented 2 years ago

This basically treats from("scratch") as any other image in order to simplify buildkit-frontend logic. buildkit.rs will "resolve" those by building the following Dockerfile:

FROM scratch

and the frontend would use Source::image(id), where id is the empty image just built.

The alternative is to use buildkit_llb::ops::exec::Mount::Scratch whenever the parent is from("scratch"), but with this approach, due to the limit of the buildkit_llb rust library, it is not possible to output from("scratch") as the final image.

Note that, also due to poor library design, resolve_image_config will fail when the image is empty. This is worked-around by treating FromScratch specially.

maowtm commented 2 years ago

(merging right now because I need it for evaluation. @mechtaev feel free to still provide any comment on this)

mechtaev commented 2 years ago

This looks reasonable, thank you!