6 releases
Uses new Rust 2024
new 0.3.0 | Apr 18, 2025 |
---|---|
0.2.1 | Apr 18, 2025 |
0.1.2 | Apr 17, 2025 |
#314 in Unix APIs
299 downloads per month
34KB
808 lines
dockerfile-parser-rs
The ultimate Rust library for parsing, modifying, and generating Dockerfiles.
Instructions
- ADD
- ARG
- CMD
- COPY
- ENTRYPOINT
- ENV
- EXPOSE
- FROM
- LABEL
- RUN
- SHELL
- USER
- VOLUME
- WORKDIR
Note: In addition to the official supported Dockerfile instructions, this library also supports placeholders for empty lines and comments.
Install
Run the following Cargo command in your project directory:
cargo add dockerfile-parser-rs
Example
use std::path::PathBuf;
use dockerfile_parser_rs::Dockerfile;
use dockerfile_parser_rs::Instruction;
fn main() {
let mut dockerfile = Dockerfile::from(PathBuf::from("Dockerfile")).unwrap();
dockerfile.instructions.push(Instruction::User {
user: String::from("1001"),
group: None,
});
dockerfile.dump().unwrap();
}
Dependencies
~2.4–4MB
~72K SLoC