dockerfmt simplifies the process of formatting Dockerfiles by providing a robust parser built on Moby's BuildKit. This tool ensures clean, organized code while accommodating modern formatting needs. With features like spaces for indentation and support for basic heredocs, it makes Dockerfile management easier and more efficient.
dockerfmt is a modern Dockerfile format and parser that enhances the functionality of the original dockfmt. This tool is built on top of the internal buildkit parser, ensuring compatibility and efficiency.
Advanced Formatting: Leverage the dockerfile parser from Moby's buildkit alongside the shell formatter from mvdan/sh for accurate formatting of Dockerfiles.
Run Step Formatting: Easily format RUN steps, including support for basic heredocs, allowing for clear and organized Dockerfile commands:
RUN <<EOF
echo "hello"
echo "world"
EOF
Inline Comment Support: Add inline comments in run steps to maintain code clarity:
RUN echo "hello" \
# this is a comment
&& echo "world"
RUN echo "hello" \
# this is a comment
# that spans multiple lines
&& echo "world"
JS Bindings: Explore the provided JavaScript bindings located in the js directory, with further details available in the README file.
To utilize dockerfmt, run the command with the following syntax:
dockerfmt [Dockerfile] [flags]
dockerfmt [command]
completion: Generate the autocompletion script for the specified shell.help: Assistance for any command.version: Display the current version number of dockerfmt.-c, --check: Verify if the file(s) are formatted.-h, --help: Provide help information for dockerfmt.-i, --indent uint: Specify the number of spaces for indentation (default is 4).-n, --newline: Ensure the file ends with a trailing newline.-w, --write: Write the reformatted output back to the file(s).RUN parser does not support command grouping or semicolons.# escape=X directive is unsupported.Contributions to the project are welcome, promoting continuous improvement and feature enhancements.
No comments yet.
Sign in to be the first to comment.