[−][src]Crate dockerfile_parser
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
ArgInstruction | A Dockerfile |
CopyFlag | A key/value pair passed to a |
CopyInstruction | A Dockerfile |
Dockerfile | A parsed Dockerfile. |
EnvInstruction | A Dockerfile |
EnvVar | An environment variable key/value pair |
FromInstruction | A Dockerfile |
ImageRef | A parsed docker image reference |
Label | A single label key/value pair. |
LabelInstruction | A Dockerfile |
MiscInstruction | A miscellaneous (unsupported) Dockerfile instruction. |
Span | A byte-index tuple representing a span of characters in a string |
Splicer | A utility to repeatedly replace spans of text within a larger document. |
Stage | A single stage in a multi-stage build. |
Stages | A collection of stages in a [multi-stage build]. |
Enums
CmdInstruction | A Dockerfile |
EntrypointInstruction | A Dockerfile |
Error | A Dockerfile parsing error. |
Instruction | A single Dockerfile instruction. |
Rule | |
RunInstruction | A Dockerfile |
StageParent | The parent image of a Docker build stage |
Type Definitions
Result | A Dockerfile parsing Result. |