Crates.io | dockerfile-rs |
lib.rs | dockerfile-rs |
version | 0.3.0 |
source | src |
created_at | 2019-02-17 10:42:53.030741 |
updated_at | 2019-04-04 20:24:16.911218 |
description | Correct Dockerfile generator library |
homepage | |
repository | https://github.com/ark0f/dockerfile.rs |
max_upload_size | |
id | 115337 |
size | 58,976 |
Correct Dockerfile
generator library
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!"]
dockerfile-rs under either of:
at your option.