reteps/dockerfmt: Dockerfile format and parser. a modern dockfmt.

Date:

Share:

Dockerfile format and parser, and a modern version of dockfmt. Built on top of the internal buildkit parser.

Binaries are available from the releases page.

A updated version of the dockfmt. Uses the dockerfile parser from moby/buildkit and the shell formatter from mvdan/sh.

Usage:
  dockerfmt [Dockerfile] [flags]
  dockerfmt [command]

Available Commands:
  completion  Generate the autocompletion script for the specified shell
  help        Help about any command
  version     Print the version number of dockerfmt

Flags:
  -c, --check         Check if the file(s) are formatted
  -h, --help          help for dockerfmt
  -i, --indent uint   Number of spaces to use for indentation (default 4)
  -n, --newline       End the file with a trailing newline
  -w, --write         Write the formatted output back to the file(s)

Use "dockerfmt [command] --help" for more information about a command.
  • The RUN parser currently doesn’t support grouping or semicolons in commands
  • No line wrapping is performed for long JSON commands
  • The # escape=X directive is not supported

Contributions are welcome!

RUN <"hello"
echo "world"
EOF
  • Support for basic inline comments in run steps:
RUN echo "hello" \
    # this is a comment
    && echo "world"
RUN echo "hello" \
    # this is a comment
    # that spans multiple lines
    && echo "world"

This is surprisingly non-trivial as we want to attach the comments to their position in the formatted output, but they are stripped by the parser beforehand.

The JS bindings are available in the js directory. More information on how to use them can be found in the README file.

Source link

Subscribe to our magazine

━ more like this

Founding Fathers Pub in Buffalo, New York

Stepping inside the Founding Fathers Pub feels like stepping straight into the pages of an American history syllabus–only this one comes with beer,...

Tom Cruise Buys Fitbit To Help Him Get 10,000 Daily Stunts

CLEARWATER, FL—Explaining that his personal health was everything to him, Tom Cruise told reporters Thursday he had purchased a Fitbit to help him get...

Elevate Your Style With These Burst Fade Haircuts For Men

Burst Fade The burst fade is a striking blend of traditional and contemporary styling, creating an eye-catching rounded fade that arches around the ear and...

Chanel Les 4 Ombres Boutons

Chanel Beauty launched new limited-edition eyeshadow palettes called the Les 4 Ombres Boutons Multi-Effect Quadra Eyeshadow ($86 each, Chanel and Nordstrom). They sold out...

Apple Watch Bands Are 70% Off Right Now

We may earn a commission from links on this page. ...