4 releases

0.1.3 Feb 24, 2019
0.1.2 Feb 24, 2019
0.1.1 Feb 24, 2019
0.1.0 Feb 24, 2019

#1963 in Development tools

Download history 2249/week @ 2024-07-23 3091/week @ 2024-07-30 3052/week @ 2024-08-06 2413/week @ 2024-08-13 2218/week @ 2024-08-20 3386/week @ 2024-08-27 3868/week @ 2024-09-03 3523/week @ 2024-09-10 3174/week @ 2024-09-17 4518/week @ 2024-09-24 3973/week @ 2024-10-01 3101/week @ 2024-10-08 2918/week @ 2024-10-15 5183/week @ 2024-10-22 4681/week @ 2024-10-29 5199/week @ 2024-11-05

18,498 downloads per month
Used in 4 crates (via risc0-build)

MIT license

9KB
180 lines

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

No runtime deps