docker-generate 0.1.3

docker file read/write
Documentation
  • Coverage
  • 0%
    0 out of 10 items documented0 out of 0 items with examples
  • Size
  • Source code size: 8.72 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.9 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 9s Average build duration of successful builds.
  • all releases: 9s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • pigeonhands/docker-generate-rs
    2 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • pigeonhands
use docker_generate::DockerFile;

let build = 
    DockerFile::new()
    .comment("build stage")
    .from_alias("build", "golang:alpine")
    .run("cd /src && go build -o goapp");
let run = 
    DockerFile::new()
    .comment("run stage")
    .from("alpine")
    .workdir("/app")
    .copy_from("build", "/src/goapp", "/app/")
    .entrypoint(&["./goapp"]);

let file = DockerFile::new()
         .dockerfile(build)
         .dockerfile(run);

println!("{}", file.to_string());
# build stage
FROM golang:alpine as build
RUN cd /src && go build -o goapp

# run stage
FROM alpine
WORKDIR /app
COPY --from=build /src/goapp /app/
ENTRYPOINT ["./goapp"]

OR

let build = 
    DockerFile::new()
    .add("#", "My app".into())
    .add("FROM", "alpine".into())
    .add("WORKDIR", "/app".into())
    .add("COPY", vec![".", "/app"].into())
    .add("CMD", DockerFieldType::Array(vec!["./app/main"]));
# My app
FROM alpine
WORKDIR /app
COPY . /app
CMD ["./app/main"]