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
31–40 of 67 posts
Re: Dockerfmt: A Dockerfile Formatter
#32> 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 use `mvdan/sh` [1] under the hood for processing the commands. So it will reformat 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. [1] http…
Re: Dockerfmt: A Dockerfile Formatter
#33Earlier quoted context omitted.
I use `mvdan/sh` [1] under the hood for processing the commands. So it will reformat 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. [1] http…
Between that and the difficulty with comments, it feels like maybe not an ideal tool for the job? Although, I can't throw stones; I'd do almost anything to avoid having to write my own parser. (And not meant as an attack regardless, just trying to constructively question this particular design point)
Re: Dockerfmt: A Dockerfile Formatter
#34Earlier quoted context omitted.
Between that and the difficulty with comments, it feels like maybe not an ideal tool for the job? Although, I can't throw stones; I'd do almost anything to avoid having to write my own parser. (And not meant as an attack regardless, just trying to constructively question this particular design point)
I am certainly not in the business of writing my own shell parser ;) Though this is a fair point -- I think I could get a more rich level of control over the output by hooking into their parser, albeit with a higher level of complexity.
Re: Dockerfmt: A Dockerfile Formatter
#35I had a chuckle when I looked at the source code and could not find a Dockerfile in there. I want to kick the tires on it and the easiest way would be to run it as a Docker container against an existing file and alas, I cannot.
Hi there — I’ll try to distribute a docker release of the binary tomorrow!
so you can still have no dockerfile and the irony is not ruined
Re: Dockerfmt: A Dockerfile Formatter
#36I had a chuckle when I looked at the source code and could not find a Dockerfile in there. I want to kick the tires on it and the easiest way would be to run it as a Docker container against an existing file and alas, I cannot.
Regarding this part, you can always just run a base image and add the app yourself. I'm on mobile so can't test, but should be along these lines:
docker run --rm --name dockerfmt \
-v /path/to/Dockerfile:/tmp/Dockerfile \
golang:1.24-alpine sh -c \
"apk add git && go run github.com/reteps/dockerfmt@latest /tmp/Dockerfile"
> against an existing fileFor this part yes, you'd still need one, but it can be any of your own.
Re: Dockerfmt: A Dockerfile Formatter
#37waaaat? 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
Is there any reason you prefer `set -e` over `&&`? I'm curious if this is a readability thing.
Re: Dockerfmt: A Dockerfile Formatter
#38> 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
#39Re: Dockerfmt: A Dockerfile Formatter
#40OK but is there any way to layer docker files? I'm not talking about compose, I mean like combining layers from different dockers in a nice way?