How can I get smaller closure sizes for use in Docker images? #75
-
I have an open-source example for an Axum + sqlx project here: Unfortunately if I use this code as-written like so: nix -vL build .#docker && ./result | docker load I get an image that pulls the entire deps tree into the runtime image, to the tune of about 350MB. The Dockerfile in the same repo produces a binary of about 18MB and a total image size of about 87MB including the base Alpine OS. I attempted to use Do you have any advice? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
Not sure how much help it will be but I had neat and slim images with https://github.com/rustshop/rustshop/blob/a8ff84a8f3d8522fb218574cb9f6b7935596aceb/flake.nix#L93 Your flake.nix looks similar. I didn't use
|
Beta Was this translation helpful? Give feedback.
-
Thanks for the report @shanesveller! This is actually a bug: #80 The tl;dr is that rust will include links to source files in panic info (e.g. line numbers) which nix sees as the final binary still "depending" on those sources. We go to some lengths to break the false-dependency but looks like it was broken and I didn't have the tests to catch it 😬 |
Beta Was this translation helpful? Give feedback.
Thanks for the report @shanesveller! This is actually a bug: #80
The tl;dr is that rust will include links to source files in panic info (e.g. line numbers) which nix sees as the final binary still "depending" on those sources. We go to some lengths to break the false-dependency but looks like it was broken and I didn't have the tests to catch it 😬