dockerfile_parser/
lib.rs

1// (C) Copyright 2019-2020 Hewlett Packard Enterprise Development LP
2
3#![forbid(unsafe_code)]
4
5//! # Rust parser for Dockerfile syntax
6//!
7//! A pure Rust library for parsing and inspecting Dockerfiles, useful for
8//! performing static analysis, writing linters, and creating automated tooling
9//! around Dockerfiles. It can provide useful syntax errors in addition to a
10//! full syntax tree.
11//!
12//! ## Quick start
13//!
14//! ```rust
15//! use dockerfile_parser::Dockerfile;
16//!
17//! let dockerfile = Dockerfile::parse(r#"
18//!   FROM alpine:3.11 as builder
19//!   RUN echo "hello world" > /hello-world
20//!
21//!   FROM scratch
22//!   COPY --from=builder /hello-world /hello-world
23//! "#).unwrap();
24//!
25//! for stage in dockerfile.iter_stages() {
26//!   println!("stage #{}", stage.index);
27//!   for ins in stage.instructions {
28//!     println!("  {:?}", ins);
29//!   }
30//! }
31//! ```
32
33#[macro_use] extern crate pest_derive;
34
35mod error;
36mod parser;
37mod util;
38mod image;
39mod instructions;
40mod splicer;
41mod stage;
42mod dockerfile_parser;
43
44pub use image::*;
45pub use error::*;
46pub use parser::*;
47pub use instructions::*;
48pub use splicer::*;
49pub use stage::*;
50pub use util::*;
51pub use crate::dockerfile_parser::*;
52
53#[cfg(test)] mod test_util;