Crate dockerfile_parser[−][src]
Expand description
Rust parser for Dockerfile syntax
A pure Rust library for parsing and inspecting Dockerfiles, useful for performing static analysis, writing linters, and creating automated tooling around Dockerfiles. It can provide useful syntax errors in addition to a full syntax tree.
Quick start
use dockerfile_parser::Dockerfile;
let dockerfile = Dockerfile::parse(r#"
FROM alpine:3.11 as builder
RUN echo "hello world" > /hello-world
FROM scratch
COPY --from=builder /hello-world /hello-world
"#).unwrap();
for stage in dockerfile.iter_stages() {
println!("stage #{}", stage.index);
for ins in stage.instructions {
println!(" {:?}", ins);
}
}
Structs
A Dockerfile ARG
instruction.
A Docker string that may be broken across several lines, separated by line
continuations (\\\n
), and possibly intermixed with comments.
A Dockerfile CMD
instruction.
A key/value pair passed to a COPY
instruction as a flag.
A Dockerfile COPY
instruction.
A parsed Dockerfile.
A Dockerfile ENTRYPOINT
instruction.
A Dockerfile ENV
instruction.
An environment variable key/value pair
A Dockerfile FROM
instruction.
A parsed docker image reference
A single label key/value pair.
A Dockerfile LABEL
instruction.
A miscellaneous (unsupported) Dockerfile instruction.
A Dockerfile RUN
instruction.
A byte-index tuple representing a span of characters in a string
A comment with a character span.
A string with a character span.
A utility to repeatedly replace spans of text within a larger document.
A single stage in a multi-stage build.
A collection of stages in a [multi-stage build].
A string array (ex. [“executable”, “param1”, “param2”])
Enums
A component of a breakable string.
A Dockerfile parsing error.
A single Dockerfile instruction.
A string that may be broken across many lines or an array of strings.
The parent image of a Docker build stage
Type Definitions
A Dockerfile parsing Result.