So is there a secret to building #Rust docker containers? When I `cargo install` or `cargo build` inside a container I end up with an image of 2.5GB 😱

#cargo #docker #rustlang #build

Follow

@kevin Cargo's cache for incremental compilation is HUGE. You may want to rm -rf it after you've got the build products you wanted. Or use Cargo's env vars to tell Cargo to store its stuff in some dir that isn't part of the image.

@kornel I figured as much, was shocked when I saw a 2.5GB container for literally a 1-file web server. :D

My problem was also that I want to use alpine linux but am not building for alpine yet because I've no idea how to configure my builds. Will need to do more research.

Sign in to participate in the conversation
Mastodon

Server run by the main developers of the project 🐘 It is not focused on any particular niche interest - everyone is welcome as long as you follow our code of conduct!