waaaat? https://github.com/reteps/dockerfmt#:~:text=The%20RUN%20pars... I am firmly in the camp of RUN set -e ;\ export DEBIAN_FRONTEND=noninteractive ;\ etc etc so I guess this tool isn't for me
Dockerfmt: A Dockerfile Formatter
21–30 of 67 posts
Re: Dockerfmt: A Dockerfile Formatter
#22Re: Dockerfmt: A Dockerfile Formatter
#23Earlier quoted context omitted.
Podman uses Dockerfiles too. Dockerfiles is the language for specifying a set of instructions for building container images.
It's not a very good one, but it is ubiquitous (it's also better if you remember to include the right syntax marker that enables heredocs): # syntax=docker/dockerfile:1 I suspect that the GP was really asking "why not use a different tool", like buildah https://buildah.io >, buildpacks https://buildpacks.io >, nix https://nix.dev/tutorials/nixos/building-and-running-docker-... >, kaniko https://github.com/GoogleConta…
Re: Dockerfmt: A Dockerfile Formatter
#24Re: Dockerfmt: A Dockerfile Formatter
#25But then example show that it does support `&&`? Why the difference? I pretty much always write
RUN foo && \
bar && \
:
but it seems syntactically identical to the also valid RUN set -e && \
foo ; \
bar ; \
:Re: Dockerfmt: A Dockerfile Formatter
#26> The RUN parser currently doesn't support grouping or semicolons in commands But then example show that it does support `&&`? Why the difference? I pretty much always write RUN foo && \ bar && \ : but it seems syntactically identical to the also valid RUN set -e && \ foo ; \ bar ; \ :
Re: Dockerfmt: A Dockerfile Formatter
#27Earlier quoted context omitted.
It's not a very good one, but it is ubiquitous (it's also better if you remember to include the right syntax marker that enables heredocs): # syntax=docker/dockerfile:1 I suspect that the GP was really asking "why not use a different tool", like buildah https://buildah.io >, buildpacks https://buildpacks.io >, nix https://nix.dev/tutorials/nixos/building-and-running-docker-... >, kaniko https://github.com/GoogleConta…
Buildah is the only serious alternative in my opinion. You lose automatic layer caching, but in exchange you can use the same tools (RUN, ADD, etc) within a much more powerful shell environment. I wrote a Buildah wrapper that uses a shell script harness to polyfill the familiar Dockerfile syntax while adding several extra goodies - mainly the ability to bake runtime arguments (mounts, ports...) into the image. Very h…
That said, in the end I'd still rather build containers with something other than an imperative sequence of commands, so my heart is going to be forever with nix2container and bazel's rules_oci.
Re: Dockerfmt: A Dockerfile Formatter
#28> The RUN parser currently doesn't support grouping or semicolons in commands But then example show that it does support `&&`? Why the difference? I pretty much always write RUN foo && \ bar && \ : but it seems syntactically identical to the also valid RUN set -e && \ foo ; \ bar ; \ :
I find it more readable and portable.
[1] https://www.docker.com/blog/introduction-to-heredocs-in-dock...
Re: Dockerfmt: A Dockerfile Formatter
#29> The RUN parser currently doesn't support grouping or semicolons in commands But then example show that it does support `&&`? Why the difference? I pretty much always write RUN foo && \ bar && \ : but it seems syntactically identical to the also valid RUN set -e && \ foo ; \ bar ; \ :
I prefer heredoc[1] syntax. I find it more readable and portable. [1] https://www.docker.com/blog/introduction-to-heredocs-in-dock...
# syntax=docker/dockerfile:1.3-labs
FROM alpine
RUN
Non-meta: Do you happen to know how portable that is across old docker, podman/buildah, kaniko, etc.? I'd like to adopt it but I don't want it to bite me when I'm not running a recent version of literal docker.Re: Dockerfmt: A Dockerfile Formatter
#30> The RUN parser currently doesn't support grouping or semicolons in commands But then example show that it does support `&&`? Why the difference? I pretty much always write RUN foo && \ bar && \ : but it seems syntactically identical to the also valid RUN set -e && \ foo ; \ bar ; \ :
if [ foo ] ; then
bar
fi
to if [ foo ]
then
bar
fi
And also format your example to foo
bar
In this type of situation, it becomes a little trickier to disambiguate when I need to add semicolons and a backslash, and when I need to add only backslashes. If you use `&&` -- you have disambiguated the two cases so I can format it.