Our great sponsors
-
WorkOS
The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.
-
sccache
Sccache is a ccache-like tool. It is used as a compiler wrapper and avoids compilation when possible. Sccache has the capability to utilize caching in remote storage environments, including various cloud storage options, or alternatively, in local storage.
-
InfluxDB
Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.
-
crustde_cnt_img_pod
CRUSTDE - Containerized Rust development environment - Hack Without Fear and Trust! (2024-03)
I did a talk (slides here) about this a few years ago, it took a bit of work to get the build caching working with cargo. As others have pointed out, there is now cargo chef to solve this problem so you probably don't have to deal with the issues I saw, but I thought it still might be helpful context.
Eventually, I think things like Dagger ( https://dagger.io/ ) / tools with programmable build stages will mature and be a bit more usable in the long run than scripting around Docker-like container engines. I guess plenty of build systems like bazel already exist, but they each seem to suck in their own special ways.
There's also sccache with docker layer caching, which writes back directly to the docker cache through some magic. https://github.com/mozilla/sccache/issues/687
It seems to be a known problem: https://github.com/docker/for-mac/issues/3677 where people specifically mention hot reloading applications taking forever. Not sure exactly what is going on, but it is not Rust specific (devs mention Ruby, Java, etc.)
I'm running into the same issues with Docker. One solution I've seen too is to utilize Nix for the build and have it create the docker image for you as well after building the binary outside of it. That's my rudimentary understanding of the flow anyway, note: just starting to learn Nix
I see you answered a good part of your question, but I might have the dockerfile you want if size/cache is still a concern: https://github.com/pluots/sql-udf/blob/273eaed142f222b75f72d28911613ff5c0740365/Dockerfile.examples
one of my dockerfiles (includes some SQLX stuff you can ignore) https://github.com/laundmo/grapple_tournament_bot/blob/f5bfb289193740ed697959f8262ba33ecc110fa2/Dockerfile