- Notifications
You must be signed in to change notification settings - Fork950
Commitdb3d8f7
committed
Optimize Docker build with bind mounts
This commit further optimize the Docker builds on top of PR#92 with:1. Add .dockerignore file to exclude non-source code files [1].2. Use Alpine image variant for build stage to reduce download size. golang:1.23.7-alpine is 200 MB smaller than golang:1.23.7 [2][3].3. Replace COPY instruction with RUN --mount=type=bind. Bind mounts do not add unnecessary layers to the cache [4][5].[1]:https://docs.docker.com/build-cloud/optimization/#dockerignore-files[2]:https://hub.docker.com/layers/library/golang/1.23.7-alpine/images/sha256-333d4ba78773b3a3ae9cf2cff8962df56effc5c9481faa355f211abf2baf175c[3]:https://hub.docker.com/layers/library/golang/1.23.7/images/sha256-2087a99c3235972660b3d35c1564d9d1a3f639dcace9c790acbabc7e938d1570[4]:https://docs.docker.com/build/building/best-practices/#add-or-copy[5]:https://docs.docker.com/build/cache/optimize/#use-bind-mountsSigned-off-by: Eng Zer Jun <engzerjun@gmail.com>1 parent7145142 commitdb3d8f7
2 files changed
+25
-10
lines changedLines changed: 11 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + |
Lines changed: 14 additions & 10 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
| 1 | + | |
1 | 2 |
| |
2 | 3 |
| |
3 |
| - | |
4 |
| - | |
5 |
| - | |
6 | 4 |
| |
7 | 5 |
| |
8 | 6 |
| |
9 |
| - | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
10 | 10 |
| |
11 | 11 |
| |
12 |
| - | |
13 |
| - | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
14 | 16 |
| |
15 |
| - | |
16 | 17 |
| |
17 |
| - | |
18 |
| - | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
19 | 23 |
| |
20 | 24 |
| |
21 | 25 |
| |
22 | 26 |
| |
23 | 27 |
| |
24 | 28 |
| |
25 |
| - | |
| 29 | + | |
26 | 30 |
| |
27 | 31 |
|
0 commit comments
Comments
(0)