modus
modus copied to clipboard
Layer expression that creates no layers
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
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
Yes, by saying "empty layer" I meant no layers, sorry for not being precise.
Is there a use case for run("")
- an actual empty layer?
If not, maybe just default to this behaviour whenever we see run("")
.
e.g.
FROM alpine
RUN []
I could be wrong but it does seem that RUN []
does not produce a layer.
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.