4 个版本

0.1.3 2019年2月24日
0.1.2 2019年2月24日
0.1.1 2019年2月24日
0.1.0 2019年2月24日

开发工具 中排名第1733

Download history 1335/week @ 2024-04-07 2174/week @ 2024-04-14 2447/week @ 2024-04-21 2594/week @ 2024-04-28 2726/week @ 2024-05-05 2916/week @ 2024-05-12 2610/week @ 2024-05-19 2254/week @ 2024-05-26 1837/week @ 2024-06-02 1945/week @ 2024-06-09 2119/week @ 2024-06-16 2536/week @ 2024-06-23 2069/week @ 2024-06-30 2966/week @ 2024-07-07 2512/week @ 2024-07-14 2136/week @ 2024-07-21

每月下载量 9,724
3 个crate中(通过 risc0-build)使用

MIT 许可证

9KB
180

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

或者

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

无运行时依赖