From 9eff5c04961da9dc2ddb05f3c4d1a6722050b394 Mon Sep 17 00:00:00 2001 From: m0veax Date: Sat, 25 May 2024 22:09:45 +0200 Subject: [PATCH] create a truly static binary and a scratch run container --- Dockerfile | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 6614f10..ae1b8d3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,9 +1,15 @@ -FROM rust:1.75.0 +FROM rust:1.75.0 as builder WORKDIR /usr/src/chaospott-status COPY . . -RUN cargo install --path . + +# use musl to create a truly static binary https://bxbrenden.github.io/ +RUN rustup component add rust-std-x86_64-unknown-linux-musl +RUN cargo build --release --target x86_64-unknown-linux-musl + +FROM scratch +COPY --from=builder /usr/src/chaospott-status/target/x86_64-unknown-linux-musl/release/chaospott-status /chaospott-status EXPOSE 3000 -CMD ["chaospott-status"] \ No newline at end of file +CMD ["/chaospott-status"] \ No newline at end of file -- 2.45.2