Commit b61723f
committed
[BUILD] Minimize docker container sizes
We use two techniques:
1) the use of a minimal docker base (FROM scratch + busybox)
2) the use of a static binary
... to create a minimally sized image for 'peer' and 'orderer'
Before this patch, these containers are approximately 1.4GB. After this
patch, they are about 20MB-24MB.
It isn't strictly necessary to include busybox. The main benefit
is achieved simply by eliminating external dependencies in the
golang binary using -static and then getting rid of all the
bloat in the baseimage via "FROM scratch". However, in this mode
the image is pathologically bare-boned. For instance, the image has
to be launched using the exec-form '["peer", "node", "start"]' since
there is no shell interpreter available to do the more natural
"CMD peer node start". Further, any "docker exec" style debugging
would be impossible. It is often helpful to jump into a container
and poke around with tools like ifconfig, ping, netstat, etc.
Enter busybox: We can create a basic unix environment with only
a 5MB payload. This is impressive and is easily worth its weight
in the image.
However, the challenge isn't really justifying the utility of having
busybox over saving 5MB as much as it is about how we will get it
into the image. If the world were a monochrome x86_64, we could simply
s/FROM scratch/FROM busybox and be done. However, we have to consider
other multi $arch. To support this, we forgo the temptation to use
FROM busybox and build busybox from source. On my 2011 Macbook Pro,
this adds about 5 minutes to the build, at least on the first build.
Subsequent builds utilize the cache in ./build and thus are no-ops.
This is _just_ fast enough that I am not embarrassed to propose it
for consideration. However, if this is perceived as a problem
we do have alternatives. For instance, we could start distributing
a multi-$arch busybox base (hyperledger/fabric-busybox:$arch), TBD.
Change-Id: I4ed20a429c2cc2e72fd602b45c5c8dd5548bc995
Signed-off-by: Greg Haskins <gregory.haskins@gmail.com>1 parent 9bd4e85 commit b61723f
File tree
5 files changed
+51
-7
lines changed- busybox
- images
- orderer
- peer
- runtime
5 files changed
+51
-7
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
| 52 | + | |
52 | 53 | | |
53 | 54 | | |
54 | 55 | | |
| |||
100 | 101 | | |
101 | 102 | | |
102 | 103 | | |
103 | | - | |
| 104 | + | |
104 | 105 | | |
105 | 106 | | |
106 | 107 | | |
| |||
160 | 161 | | |
161 | 162 | | |
162 | 163 | | |
163 | | - | |
| 164 | + | |
164 | 165 | | |
165 | 166 | | |
166 | | - | |
| 167 | + | |
167 | 168 | | |
168 | | - | |
| 169 | + | |
169 | 170 | | |
170 | 171 | | |
171 | 172 | | |
| |||
181 | 182 | | |
182 | 183 | | |
183 | 184 | | |
184 | | - | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
185 | 191 | | |
186 | 192 | | |
187 | 193 | | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
188 | 198 | | |
189 | 199 | | |
190 | 200 | | |
| |||
205 | 215 | | |
206 | 216 | | |
207 | 217 | | |
| 218 | + | |
208 | 219 | | |
209 | 220 | | |
210 | 221 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
0 commit comments