Commit 44e5971
committed
build(gateway): stop reinstalling the toolchain on every fixture build
The workspace pins a channel plus rustfmt, clippy, rust-analyzer and three
targets that the base image does not carry and this build does not need, so the
first cargo invocation makes rustup download and install a complete toolchain.
That step sat after `COPY . .`, which is the whole repo -- so any change
anywhere redid it, in both fixture images, on every push, in all three gateway
workflows.
It is ~27s per image and it was the bulk of the cost. Measured on an unrelated
one-line change: cargo itself reported `Finished in 2.48s`, inside a 29.6s
step.
Copying the toolchain file onto a layer of its own keys that work on the pin
rather than on the source tree. The cargo registry, git and target directories
become BuildKit cache mounts, which survive the `COPY . .` invalidation and are
shared by both images, so whichever builds second reuses the first's artifacts.
The binary is copied out inside the RUN because a cache mount is not part of the
resulting layer.
Same machine, same kind of change:
unrelated file 1m57s -> 4.2s
real dependency 45.6s, recompiling six crates
The second number is the check that the first is not a false cache hit.1 parent 35bbd1f commit 44e5971
2 files changed
Lines changed: 60 additions & 6 deletions
Lines changed: 30 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
6 | 29 | | |
7 | | - | |
8 | | - | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
9 | 36 | | |
10 | 37 | | |
11 | 38 | | |
12 | 39 | | |
13 | 40 | | |
14 | | - | |
| 41 | + | |
15 | 42 | | |
16 | 43 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
6 | 29 | | |
7 | | - | |
8 | | - | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
9 | 36 | | |
10 | 37 | | |
11 | 38 | | |
12 | 39 | | |
13 | 40 | | |
14 | 41 | | |
15 | | - | |
| 42 | + | |
16 | 43 | | |
17 | 44 | | |
18 | 45 | | |
| |||
0 commit comments