https://github.com/escapace/dockerfile-tools
https://github.com/escapace/dockerfile-tools
Last synced: about 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/escapace/dockerfile-tools
- Owner: escapace
- License: apache-2.0
- Created: 2024-12-05T07:43:32.000Z (over 1 year ago)
- Default Branch: trunk
- Last Pushed: 2025-04-26T07:58:26.000Z (about 1 year ago)
- Last Synced: 2025-06-09T11:04:08.491Z (about 1 year ago)
- Language: Go
- Size: 35.2 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# dockerfile-tools
A command-line application designed to assist with analyzing and extracting
information from Dockerfiles. It provides three main functionalities: generating a
JSON Abstract Syntax Tree (AST) from a Dockerfile, listing the build stages defined
within a Dockerfile, and listing cache mounts in RUN instructions.
## Usage
The application provides the following commands:
### ast
Generates a JSON AST from a specified Dockerfile.
#### Options
- `--dockerfile string`: Path to the Dockerfile.
- `--help`: Display help information for the `ast` command.
#### Example
```bash
dockerfile-tools ast --dockerfile path/to/Dockerfile
```
### list-stages
Lists the build stages of a specified Dockerfile.
#### Options
- `--dockerfile string`: Path to the Dockerfile.
- `--help`: Display help information for the `list-stages` command.
#### Example
```bash
dockerfile-tools list-stages --dockerfile path/to/Dockerfile
```
### list-cache-mounts
Extracts --mount=type=cache flags from RUN instructions in a Dockerfile and outputs a JSON object.
The target paths are used as the values, while the keys are derived by replacing / with spaces and
converting the result to kebab-case. The output is compatible with the `cache-map` option of
[buildkit-cache-dance](https://github.com/reproducible-containers/buildkit-cache-dance), making it
easier to define cache mappings for reproducible builds.
#### Options
- `--dockerfile string`: Path to the Dockerfile.
- `--arg`: comma-delimited ARG key-value pairs
- `--help`: Display help information for the `list-cache-mounts` command.
#### Example
```bash
dockerfile-tools list-cache-mounts --dockerfile path/to/Dockerfile \
--arg BUILDPLATFORM=linux/amd64 --arg BUILDOS=linux,BUILDARCH=amd64
```
## Help
For general help, run the application without any arguments:
```bash
dockerfile-tools
```
This will display a list of available commands and their descriptions.