#docker #dockerfile #generator

dockerfile-rs

Correct Dockerfile generator library

6 releases

0.3.0 Apr 4, 2019
0.2.3 Feb 23, 2019
0.1.1 Feb 17, 2019

#330 in Configuration

Apache-2.0 OR MIT

46KB
1.5K SLoC

dockerfile-rs

Build Status License crates.io API docs Codecov

Correct Dockerfile generator library

Quick start

use std::{io::{Result, Write}, fs::File};
use dockerfile_rs::{DockerFile, FROM};

fn main() -> Result<()> {
    let docker_file = DockerFile::from(FROM!(nginx:latest))
        .comment("open port for server")
        .expose(80)
        .copy((".", "."))
        .cmd(vec!["echo", "Hello from container!"]);

    // write into file
    let mut file = File::create("nginx.Dockerfile")?;
    write!(&mut file, "{}", docker_file)?;
    
    Ok(())
}

Generated file:

FROM nginx:latest

# open port for server
EXPOSE 80
COPY . .

CMD ["echo", "Hello from container!"]

Changelog

License

dockerfile-rs under either of:

at your option.

No runtime deps