Skip to content

ark0f/dockerfile.rs

Repository files navigation

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!"]

License

dockerfile-rs under either of:

at your option.

About

Dockerfile builder in Rust

Topics

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE.md
MIT
LICENSE-MIT.md

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages