Hacker News new | past | comments | ask | show | jobs | submit login
Deploying a Static Rust App in a Barebones Docker Container (anderspitman.net)
2 points by apitman on June 20, 2018 | hide | past | favorite | 1 comment



You can wrap up the build and the copy with a multi-stage docker build. Something like the following.

    FROM rust:latest

    RUN rustup target install x86_64-unknown-linux-musl
    COPY . /src
    WORKDIR /src
    RUN cargo build --release --target=x86_64-unknown-linux-musl

    FROM scratch

    COPY --from=0 /src/target/x86_64-unknown-linux-musl/release/rust_docker_barebones /rust_docker_barebones
    ENTRYPOINT ["/rust_docker_barebones"]
Although, I typically recommend _not_ using the scratch container unless you really need something that tiny. It makes debugging very difficult if you don't at a minimum have a shell and a package manager.

Also, packaging up rust to be static like this can take some extra steps. For example, loading in root certificates.




Consider applying for YC's Summer 2025 batch! Applications are open till May 13

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: