modus icon indicating copy to clipboard operation
modus copied to clipboard

Layer expression that creates no layers

Open mechtaev opened this issue 2 years ago • 5 comments

We can consider providing a predicate that creates an empty layer, say empty_layer or skip:

install_dependencies("debian:bullseye-slim") :- run("apt-get install iproute2").
install_dependencies("debian:bullseye") :- skip.

A concrete use case is here: https://github.com/modus-continens/openjdk-images-case-study/blob/fa02585eac8676b69918ad0dc53976be33ab29b4/linux.Modusfile#L59

mechtaev avatar Apr 07 '22 13:04 mechtaev

Actually for that we just need something that acts like a layer expression but creates no layer, rather than introducing redundant layers in the image. Maybe we can just make a skip predicate that the build planner just carries any parent node forward

maowtm avatar Apr 07 '22 14:04 maowtm

Yes, by saying "empty layer" I meant no layers, sorry for not being precise.

mechtaev avatar Apr 07 '22 14:04 mechtaev

Is there a use case for run("") - an actual empty layer? If not, maybe just default to this behaviour whenever we see run("").

thevirtuoso1973 avatar Apr 07 '22 14:04 thevirtuoso1973

e.g.

FROM alpine
RUN []

I could be wrong but it does seem that RUN [] does not produce a layer.

thevirtuoso1973 avatar Apr 07 '22 14:04 thevirtuoso1973

I tried runnig

FROM alpine
RUN []
RUN sleep 1s

and then

FROM alpine
RUN sleep 1s

The sleep command was not cached, so seems like it still creates a layer.

mechtaev avatar Apr 07 '22 18:04 mechtaev