buildkit icon indicating copy to clipboard operation
buildkit copied to clipboard

linter: add lint rule for required json arguments

Open jsternberg opened this issue 1 year ago • 0 comments

This lint requires json arguments to be used when the SHELL command isn't used previously for ENTRYPOINT and CMD. This is because using non-json arguments can block signals from properly being handled when used in shell mode.

We only check for the SHELL command within the dockerfile itself and this lint does not attempt to check if external images have set the shell, instead opting to assume they haven't. This should work for most situations, but it will cause a false positive with this rule if the external image does have a shell set. To workaround this limitation, you can just use the same SHELL command within the dockerfile itself to be explicit.

As an example, if mycustomshell sets the default shell to customshell, we can include it like this:

FROM mycustomshell AS mycustomshell-base
SHELL ["/usr/bin/customshell"]

FROM mycustomshell-base
...

This might result in some small amount of duplication, but will cause the lint to pass.

In general, it is not advised to use the shell format at all. JSON arguments should be used in most cases anyway with invocations of a shell being explicit rather than implicit.

jsternberg avatar Apr 26 '24 20:04 jsternberg