-
Notifications
You must be signed in to change notification settings - Fork 17
Description
Originally posted by @AbcSxyZ in #6 (comment)
Separation of declaration and execution is not the rule in Dockerfile.
For exemple, php & golang are mixing declaration and execution. And probably all other Docker official images.
It's even a recommendation to use the cache with more efficiency, from cacheability recommendation:
Ensure that lines which are less likely to change come before lines that are more likely to change (with the caveat that each line should generate an image that still runs successfully without assumptions of later lines).
For example, the line that contains the software version number (
ENV MYSOFTWARE_VERSION 4.2) should come after a line that sets up the APT repository.listfile (RUN echo 'deb http://example.com/mysoftware/debian some-suite main' > /etc/apt/sources.list.d/mysoftware.list).
Doing all declarations at the top of a Dockerfile is defeating the utility of caching mechanism.