TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Is it possible to get fast Rust compiles in a Docker container?

2 pointsby anthlaxover 2 years ago
Full disclosure: I&#x27;m the author of [this article](https:&#x2F;&#x2F;medium.com&#x2F;p&#x2F;28bda21dbee9), which got a ton of... mixed reviews here and elsewhere. I do greatly enjoy writing Rust. It&#x27;s my go-to when developing CLI&#x27;s. I just cannot get it to work for this usecase.<p>I personally love working on projects that run full-stack locally: I find the dev feedback loop is the best. I also like to be able to just `docker-compose up` my entire project, so I tend to develop with the services inside containers.<p>My issue with using rust for my backend right now is that the compiles in the container are so slow. They take around 1 minute for the basic actix-web project (when just compiling the project, none of the dependencies), which completely kills the feedback loop I&#x27;m looking for. I do the same exact thing with Golang and it works much, much faster: the compiles are almost unnoticeable.<p>Is what I&#x27;m asking for impossible? When I just compile outside the container it takes not even 2 seconds.<p>[Here&#x27;s the dockerfile in question](https:&#x2F;&#x2F;gist.github.com&#x2F;d320d0bcbfe91f90c1d13364dc75daf8) (I&#x27;m on an M1 Mac, so I thought maybe using an arm container could help to skip translation)<p>[and here&#x27;s the Actix web project](https:&#x2F;&#x2F;gist.github.com&#x2F;92fa49a008f58c2f6cac897fa75b93a2) (although it&#x27;s just the default starter project)<p>To be perfectly clear: I am *not* rebuilding the container from scratch over and over. I am *compiling* the project inside the container. As in:<p>``` Compiling fns v0.1.0 (&#x2F;src) Finished dev [unoptimized + debuginfo] target(s) in 1m 28s Running `target&#x2F;debug&#x2F;fns` ```<p>the vast majority of the advice on the reddit post about my article was how to speed up the container builds. The container builds are not that big of a deal to me! I thought I was clear about this, but since so many people thought that was what I was talking about, it was clearly a communication error on my part. Sorry about that.<p>I am NOT talking about the first compile. When I make a change to the code, Cargo watch triggers and recompiles. I am talking about the 1 + nth compile!<p>TIA!

no comments

no comments