I propose an improvement style for RUN directives in Dockerfiles.
In a nutshell, it is a shift from
RUN dnf install -y --setopt=tsflags=nodocs \
httpd vim && \
systemctl enable httpd && \
dnf clean all
to
RUN true \
&& dnf install -y --setopt=tsflags=nodocs \
httpd vim \
&& systemctl enable httpd \
&& dnf clean all \
&& true
Advantages of using this style include:
Easier movement of commands between RUN sections, easier reordering of commands (especially with line-oriented editors s.a. vim), which also leads to
cleaner git history, and
better view over how many lines a command spans.
I don't perceive the current proposed RUN formatting style as flawed, but this one is better in some aspects and not worse in a single aspect.
Moreover, if you will use this style for a while, you will not want to go back.
I propose an improvement style for RUN directives in Dockerfiles.
In a nutshell, it is a shift from
to
Advantages of using this style include:
I don't perceive the current proposed RUN formatting style as flawed, but this one is better in some aspects and not worse in a single aspect. Moreover, if you will use this style for a while, you will not want to go back.