- Notifications
You must be signed in to change notification settings - Fork11
Dockerfile formatter. a modern dockfmt.
License
reteps/dockerfmt
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Dockerfile formatter, and a modern version ofdockfmt. Built on top of the internalbuildkit parser.
Binaries are available from thereleases page.
go install github.com/reteps/dockerfmt@latest
docker run --rm -v$(pwd):/pwd ghcr.io/reteps/dockerfmt:latest /pwd/tests/in/run2.dockerfile
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 dockerfmtFlags: -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 -s, --space-redirects Redirect operators will be followed by a space -w, --write Write the formatted output back to the file(s)Use "dockerfmt [command] --help" for more information about a command.
You can add the following entry to your.pre-commit-config.yaml
file to usedockerfmt
as a pre-commit hook:
repos: -repo:https://github.com/reteps/dockerfmt# run `pre-commit autoupdate` to pin the versionrev:mainhooks: -id:dockerfmtargs:# optional: add additional arguments here ---indent=4
The
RUN
parser currently doesn't support grouping or semicolons in commands. Adding semicolon support is a non-trivial task.No line wrapping is performed for long JSON commands
The
# escape=X
directive is not supported
Contributions are welcome!
- This is not production software until the
1.0.0
release, please treat it as such. - Please file issues for any bugs or feature requests!
- Format
RUN
steps withhttps://github.com/mvdan/sh - Support for basic heredocs:
RUN <<EOFecho"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 surprisinglynon-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 thejs
directory. More information on how to use them can be found in theREADME file.
About
Dockerfile formatter. a modern dockfmt.
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.