dockerfiles
dockerfiles copied to clipboard
Use the rust-analyzer package from the alpine repo
The rust-analyzer binary is already in the edge/community package repository from Alpine. Using this package instead of the component from rustup makes the container 500 MB smaller and avoids using the nightly toolchain.
Dang! This is a great catch - we were just talking about image sizes on stream. I will test this out now!
So I tested this - one thing to note is the previous image was probably about 500mb more due to the tooling that was also included (formatter, etc). With this approach - we are removing those tools and just installing the rust-analyzer.
I don't know what the best option is here as when you try to do something like format in neovim
it fails saying rust formatter is not present. This will be the case for any tool that isn't installed in the container.
I would love to get feedback on IF we want this or not because we have other LSPs that also do this (Go comes to mind).
Oh that is a good point... For formatting the code I use formatter.nvim, which uses the rustfmt
binary on my system.
But I can see that it is also installed on the container, if someone wants that.
Is there any other tool that should be installed?
So I tried a couple of things, but even with the minimal profile of the rust toolchain we end up with a 1.57 GB container. Compared to the 934 MB with "only" rust-analyzer
. I'm not sure if the extra 600 MB just for rustfmt is worth it...
To follow up on this - I think having formatting out of the box is pretty important to provide the best developer experience possible. I also think part of the challenge here is these tools are just really bulky. We can try merging this but I do think we'd want to include the formatter as it integrates directly with the LSP before we do.
Can we just add the rustfmt
package to the apk add
line? It's only 5MB, while saving 500MB.