Commit e2c007a
committed
feat: optimize build time by removing unnecessary I/O
This PR contains two optimizations:
* reorder steps to make variant + dependencies layers cacheable
* promote first dependency to base image for 'scratch' builds
First optimization is pretty simple, given that many packages contain
same top dependencies:
```yaml
dependencies:
- stage: base
```
It makes sure LLB is ordered so that base part of the LLB up to the
dependencies is identical across packages builds and can be eliminated
to a single instance.
Second optimization is more tricky, for `scratch` packages:
```yaml
variant: scratch
dependencies:
- stage: tools
- stage: libressl
```
It promotes `tools` to be base image (instead of scratch). To compare,
in `Dockerfile` syntax it means replacing:
```
FROM scratch
COPY --from=tools / /
COPY --from=libressl / /
```
with:
```
FROM tools
COPY --from=libressl / /
```
If the `tools` layer is huge (which is often the case, in order of 0.5
GiB), it removes a lot of file copy operations and improves build time.
Signed-off-by: Andrey Smirnov <[email protected]>1 parent 384f28d commit e2c007a
2 files changed
+56
-28
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | | - | |
| 30 | + | |
| 31 | + | |
31 | 32 | | |
32 | 33 | | |
| 34 | + | |
| 35 | + | |
33 | 36 | | |
34 | 37 | | |
35 | 38 | | |
| |||
72 | 75 | | |
73 | 76 | | |
74 | 77 | | |
75 | | - | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
76 | 83 | | |
77 | 84 | | |
78 | 85 | | |
| |||
81 | 88 | | |
82 | 89 | | |
83 | 90 | | |
84 | | - | |
| 91 | + | |
85 | 92 | | |
86 | | - | |
| 93 | + | |
87 | 94 | | |
88 | 95 | | |
89 | 96 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| 36 | + | |
| 37 | + | |
36 | 38 | | |
37 | 39 | | |
38 | 40 | | |
| |||
45 | 47 | | |
46 | 48 | | |
47 | 49 | | |
48 | | - | |
49 | | - | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
50 | 62 | | |
51 | 63 | | |
52 | 64 | | |
| |||
70 | 82 | | |
71 | 83 | | |
72 | 84 | | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
73 | 101 | | |
74 | 102 | | |
75 | 103 | | |
| |||
96 | 124 | | |
97 | 125 | | |
98 | 126 | | |
99 | | - | |
100 | | - | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | | - | |
107 | | - | |
108 | | - | |
109 | | - | |
110 | | - | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
111 | 131 | | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
116 | 135 | | |
117 | 136 | | |
118 | 137 | | |
119 | 138 | | |
120 | | - | |
| 139 | + | |
121 | 140 | | |
122 | 141 | | |
123 | 142 | | |
| |||
229 | 248 | | |
230 | 249 | | |
231 | 250 | | |
232 | | - | |
233 | | - | |
234 | 251 | | |
235 | 252 | | |
236 | 253 | | |
237 | 254 | | |
238 | | - | |
239 | | - | |
240 | | - | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
241 | 259 | | |
242 | 260 | | |
243 | 261 | | |
244 | 262 | | |
245 | 263 | | |
246 | 264 | | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
247 | 268 | | |
248 | 269 | | |
249 | 270 | | |
| |||
0 commit comments