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.