Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Dockerfile formatter. a modern dockfmt.

License

NotificationsYou must be signed in to change notification settings

reteps/dockerfmt

Repository files navigation

Dockerfile formatter, and a modern version ofdockfmt. Built on top of the internalbuildkit parser.

Installation

Binaries

Binaries are available from thereleases page.

go install

go install github.com/reteps/dockerfmt@latest

docker

docker run --rm -v$(pwd):/pwd ghcr.io/reteps/dockerfmt:latest /pwd/tests/in/run2.dockerfile

Usage

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.

Pre-commit

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

Limitations

  • TheRUN 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!

Issues

  • This is not production software until the1.0.0 release, please treat it as such.
  • Please file issues for any bugs or feature requests!

Features

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.

JS Bindings

The JS bindings are available in thejs directory. More information on how to use them can be found in theREADME file.


[8]ページ先頭

©2009-2025 Movatter.jp