Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR aims to improve the time it takes to build a Rust wrapper with Polywrap's CLI, by optimizing Docker's build image.
This is done, mainly, by copying over the Cargo manifests, building dependencies, and then copying the actual source code and rebuilding. With this trick, the copying of the source files doesn't invalidate Docker's cache at the dependencies building layer. Thus saving time when changing the source code and rebuilding (which is the most common iteration when developing a Rust wrapper).
I've also added a test to measure build times, comparing the previous image with the new one by measuring: the time it takes to build each image for the first time, the time it takes to build them again (with the image cached) and the time they take to build after modying the source code in each. I've set this test to be skipped by default as it would heavily increase the CI and overall testing times.
Below is a chart with the average results I've got:
In general, the first build takes a bit more, subsequent builds take less.