dockerfiles icon indicating copy to clipboard operation
dockerfiles copied to clipboard

Use the rust-analyzer package from the alpine repo

Open B3RR10 opened this issue 2 years ago • 6 comments

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.

B3RR10 avatar May 15 '22 15:05 B3RR10

Dang! This is a great catch - we were just talking about image sizes on stream. I will test this out now!

erikreinert avatar May 17 '22 17:05 erikreinert

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).

erikreinert avatar May 17 '22 18:05 erikreinert

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?

B3RR10 avatar May 18 '22 08:05 B3RR10

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...

B3RR10 avatar May 18 '22 18:05 B3RR10

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.

erikreinert avatar Jun 17 '22 07:06 erikreinert

Can we just add the rustfmt package to the apk add line? It's only 5MB, while saving 500MB.

WhyNotHugo avatar Mar 04 '24 14:03 WhyNotHugo