Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve Mbed Docker image used by Build example - Mbed OS workflow #10297

Merged
merged 2 commits into from
Oct 23, 2021

Conversation

electrocucaracha
Copy link
Collaborator

Problem

Hadolint tool helps to build Docker images following best practices. Using those guidelines can help to reduce the size of the image and speed up the pulling process during the CI execution.

Change overview

This change uses the multi-stage builds feature to get the Arm Mbed OS, ARM Toolchain and OpenOCD sources in one stage and installing it in the following stage. As result the image size has been reduced from 4.05GB to 3.18GB

Testing

This was tested locally using the act tool ($ act -j mbedos) using the Docker image built with these changes.

@pullapprove pullapprove bot requested a review from yunhanw-google October 6, 2021 23:12
@pullapprove pullapprove bot requested a review from kghost October 6, 2021 23:12
@electrocucaracha electrocucaracha removed the request for review from kghost October 6, 2021 23:12
@pullapprove pullapprove bot requested a review from kghost October 6, 2021 23:13
@github-actions
Copy link

github-actions bot commented Oct 21, 2021

PR #10297: Size comparison from 342d1d3 to 9765f02

2 builds (for p6, telink)
platform target config section 342d1d3 9765f02 change % change
p6 lock-app default .bss 68208 68208 0 0.0
.data 2416 2416 0 0.0
.heap 962720 962720 0 0.0
.text 1126120 1126120 0 0.0
telink lighting-app tlsr9518adk80d bss 70992 70992 0 0.0
noinit 33216 33216 0 0.0
text 457856 457856 0 0.0
20 builds (for efr32, k32w, linux, mbed, qpg)
platform target config section 342d1d3 9765f02 change % change
efr32 lighting-app BRD4161A .bss 118028 118028 0 0.0
.data 1800 1800 0 0.0
.text 782488 782488 0 0.0
lock-app BRD4161A .bss 115884 115884 0 0.0
.data 1760 1760 0 0.0
.text 761624 761624 0 0.0
window-app BRD4161A .bss 116204 116204 0 0.0
.data 1764 1764 0 0.0
.text 762540 762540 0 0.0
lighting-app BRD4161A+rpc .bss 131356 131356 0 0.0
.data 1852 1852 0 0.0
.text 762204 762204 0 0.0
k32w lock-app k32w061+debug .bss 69060 69060 0 0.0
.data 1864 1864 0 0.0
.text 515232 515232 0 0.0
shell k32w061+debug .bss 55080 55080 0 0.0
.data 672 672 0 0.0
.text 357384 357384 0 0.0
lighting-app k32w061+se05x+release .bss 78584 78584 0 0.0
.data 1900 1900 0 0.0
.text 614016 614016 0 0.0
linux all-clusters-app debug .bss 52176 52176 0 0.0
.data 978 978 0 0.0
.data.rel.ro 59072 59072 0 0.0
.dynamic 592 592 0 0.0
.got 4080 4080 0 0.0
.init 27 27 0 0.0
.init_array 512 512 0 0.0
.rodata 136149 136149 0 0.0
.text 1340290 1340290 0 0.0
chip-tool debug .bss 17520 17520 0 0.0
.data 1584 1584 0 0.0
.data.rel.ro 91920 91920 0 0.0
.dynamic 592 592 0 0.0
.got 4344 4344 0 0.0
.init 27 27 0 0.0
.init_array 416 416 0 0.0
.rodata 183300 183300 0 0.0
.text 3454517 3454517 0 0.0
ota-provider-app debug .bss 37440 37440 0 0.0
.data 752 752 0 0.0
.data.rel.ro 23176 23176 0 0.0
.dynamic 592 592 0 0.0
.got 4008 4008 0 0.0
.init 27 27 0 0.0
.init_array 440 440 0 0.0
.rodata 109928 109928 0 0.0
.text 1008258 1008258 0 0.0
ota-requestor-app debug .bss 205696 205696 0 0.0
.data 752 752 0 0.0
.data.rel.ro 24488 24488 0 0.0
.dynamic 592 592 0 0.0
.got 4136 4136 0 0.0
.init 27 27 0 0.0
.init_array 512 512 0 0.0
.rodata 128072 128072 0 0.0
.text 1126994 1126994 0 0.0
shell debug .bss 16072 16072 0 0.0
.data 242 242 0 0.0
.data.rel.ro 35120 35120 0 0.0
.dynamic 592 592 0 0.0
.got 3496 3496 0 0.0
.init 27 27 0 0.0
.init_array 336 336 0 0.0
.rodata 71823 71823 0 0.0
.text 569778 569778 0 0.0
tv-app debug .bss 216560 216560 0 0.0
.data 2032 2032 0 0.0
.data.rel.ro 56096 56096 0 0.0
.dynamic 592 592 0 0.0
.got 4400 4400 0 0.0
.init 27 27 0 0.0
.init_array 608 608 0 0.0
.rodata 152680 152680 0 0.0
.text 1441618 1441618 0 0.0
bridge-app debug+rpc .bss 52880 52880 0 0.0
.data 976 976 0 0.0
.data.rel.ro 25784 25784 0 0.0
.dynamic 592 592 0 0.0
.got 3944 3944 0 0.0
.init 27 27 0 0.0
.init_array 400 400 0 0.0
.rodata 110524 110524 0 0.0
.text 1049397 1049397 0 0.0
lighting-app debug+rpc .bss 42200 42200 0 0.0
.data 1106 1106 0 0.0
.data.rel.ro 52496 52496 0 0.0
.dynamic 608 608 0 0.0
.got 4104 4104 0 0.0
.init 27 27 0 0.0
.init_array 528 528 0 0.0
.rodata 127697 127697 0 0.0
.text 1249586 1249586 0 0.0
mbed lighting-app CY8CPROTO_062_4343W+release .bss 172092 172092 0 0.0
.data 5464 5464 0 0.0
.heap 858888 858888 0 0.0
.text 1219792 1219792 0 0.0
lock-app CY8CPROTO_062_4343W+release .bss 171012 171012 0 0.0
.data 5432 5432 0 0.0
.heap 860000 860000 0 0.0
.text 1197624 1197624 0 0.0
qpg lighting-app qpg6100+debug .bss 53552 53552 0 0.0
.data 996 996 0 0.0
.text 486196 486196 0 0.0
lock-app qpg6100+debug .bss 52496 52496 0 0.0
.data 952 952 0 0.0
.text 462272 462272 0 0.0
persistent-storage-app qpg6100+debug .bss 17778 17778 0 0.0
.data 280 280 0 0.0
.text 102732 102732 0 0.0
12 builds (for esp32, nrfconnect)
platform target config section 342d1d3 9765f02 change % change
esp32 all-clusters-app c3devkit .dram0.bss 60288 60288 0 0.0
.dram0.data 16200 16200 0 0.0
.flash.rodata 199032 199032 0 0.0
.flash.text 872386 872386 0 0.0
.iram0.text 57330 57330 0 0.0
m5stack .dram0.bss 62792 62792 0 0.0
.dram0.data 32084 32084 0 0.0
.flash.rodata 207784 207784 0 0.0
.flash.text 903387 903475 88 0.0
.iram0.text 125115 125115 0 0.0
nrfconnect lighting-app nrf52840dk_nrf52840 bss 113172 113172 0 0.0
rodata 97740 97740 0 0.0
text 577384 577384 0 0.0
lock-app nrf52840dk_nrf52840 bss 112240 112240 0 0.0
rodata 94076 94076 0 0.0
text 558872 558872 0 0.0
pigweed-app nrf52840dk_nrf52840 bss 51824 51824 0 0.0
rodata 45776 45776 0 0.0
text 339456 339456 0 0.0
pump-app nrf52840dk_nrf52840 bss 112308 112308 0 0.0
rodata 95056 95056 0 0.0
text 562028 562028 0 0.0
pump-controller-app nrf52840dk_nrf52840 bss 112248 112248 0 0.0
rodata 94136 94136 0 0.0
text 558664 558664 0 0.0
shell nrf52840dk_nrf52840 bss 109068 109068 0 0.0
rodata 71644 71644 0 0.0
text 519084 519084 0 0.0
lighting-app nrf52840dk_nrf52840+rpc bss 109416 109416 0 0.0
rodata 88524 88524 0 0.0
text 550584 550584 0 0.0
nrf5340dk_nrf5340_cpuapp bss 114548 114548 0 0.0
rodata 92980 92980 0 0.0
text 506852 506852 0 0.0
lock-app nrf5340dk_nrf5340_cpuapp bss 113612 113612 0 0.0
rodata 89336 89336 0 0.0
text 488336 488336 0 0.0
shell nrf5340dk_nrf5340_cpuapp bss 110052 110052 0 0.0
rodata 66288 66288 0 0.0
text 439696 439696 0 0.0

@woody-apple
Copy link
Contributor

/rebase

@woody-apple
Copy link
Contributor

ping @electrocucaracha - I can speed this along if you up the docker version :)

@github-actions
Copy link

PR #10297: Size comparison from a0cd671 to 5d5429b

8 builds (for k32w, p6, qpg, telink)
platform target config section a0cd671 5d5429b change % change
k32w lock-app k32w061+debug .bss 69068 69068 0 0.0
.data 1864 1864 0 0.0
.text 516024 516024 0 0.0
shell k32w061+debug .bss 55080 55080 0 0.0
.data 672 672 0 0.0
.text 359480 359480 0 0.0
lighting-app k32w061+se05x+release .bss 78592 78592 0 0.0
.data 1900 1900 0 0.0
.text 614788 614788 0 0.0
p6 lock-app default .bss 68216 68216 0 0.0
.data 2416 2416 0 0.0
.heap 962712 962712 0 0.0
.text 1126688 1126688 0 0.0
qpg lighting-app qpg6100+debug .bss 53464 53464 0 0.0
.data 1004 1004 0 0.0
.text 486036 486036 0 0.0
lock-app qpg6100+debug .bss 52408 52408 0 0.0
.data 960 960 0 0.0
.text 462120 462120 0 0.0
persistent-storage-app qpg6100+debug .bss 27752 27752 0 0.0
.data 372 372 0 0.0
.text 149896 149896 0 0.0
telink lighting-app tlsr9518adk80d bss 71000 71000 0 0.0
noinit 33216 33216 0 0.0
text 457612 457612 0 0.0

@github-actions
Copy link

PR #10297: Size comparison from e282eec to ca6042e

35 builds (for efr32, esp32, k32w, linux, mbed, nrfconnect, p6, qpg, telink)
platform target config section e282eec ca6042ea change % change
efr32 lighting-app BRD4161A .bss 118036 118036 0 0.0
.data 1800 1800 0 0.0
.text 784296 784296 0 0.0
lock-app BRD4161A .bss 115884 115884 0 0.0
.data 1760 1760 0 0.0
.text 763440 763440 0 0.0
window-app BRD4161A .bss 116204 116204 0 0.0
.data 1764 1764 0 0.0
.text 764356 764356 0 0.0
lighting-app BRD4161A+rpc .bss 131364 131364 0 0.0
.data 1852 1852 0 0.0
.text 764012 764012 0 0.0
esp32 all-clusters-app c3devkit .dram0.bss 60296 60296 0 0.0
.dram0.data 16440 16440 0 0.0
.flash.rodata 199912 199912 0 0.0
.flash.text 874326 874326 0 0.0
.iram0.text 57564 57564 0 0.0
m5stack .dram0.bss 62808 62808 0 0.0
.dram0.data 32084 32084 0 0.0
.flash.rodata 208648 208648 0 0.0
.flash.text 905335 905335 0 0.0
.iram0.text 125115 125115 0 0.0
k32w lock-app k32w061+debug .bss 69068 69068 0 0.0
.data 1864 1864 0 0.0
.text 516024 516024 0 0.0
shell k32w061+debug .bss 55080 55080 0 0.0
.data 672 672 0 0.0
.text 359480 359480 0 0.0
lighting-app k32w061+se05x+release .bss 78592 78592 0 0.0
.data 1900 1900 0 0.0
.text 614788 614788 0 0.0
linux all-clusters-app debug .bss 52208 52208 0 0.0
.data 978 978 0 0.0
.data.rel.ro 60384 60384 0 0.0
.dynamic 592 592 0 0.0
.got 4088 4088 0 0.0
.init 27 27 0 0.0
.init_array 512 512 0 0.0
.rodata 136437 136437 0 0.0
.text 1352610 1352610 0 0.0
chip-tool debug .bss 17712 17712 0 0.0
.data 1584 1584 0 0.0
.data.rel.ro 93584 93584 0 0.0
.dynamic 592 592 0 0.0
.got 4368 4368 0 0.0
.init 27 27 0 0.0
.init_array 416 416 0 0.0
.rodata 194148 194148 0 0.0
.text 3506501 3506501 0 0.0
ota-provider-app debug .bss 37472 37472 0 0.0
.data 752 752 0 0.0
.data.rel.ro 24488 24488 0 0.0
.dynamic 592 592 0 0.0
.got 4016 4016 0 0.0
.init 27 27 0 0.0
.init_array 440 440 0 0.0
.rodata 110312 110312 0 0.0
.text 1022578 1022578 0 0.0
ota-requestor-app debug .bss 205728 205728 0 0.0
.data 752 752 0 0.0
.data.rel.ro 25800 25800 0 0.0
.dynamic 592 592 0 0.0
.got 4144 4144 0 0.0
.init 27 27 0 0.0
.init_array 512 512 0 0.0
.rodata 128392 128392 0 0.0
.text 1141106 1141106 0 0.0
shell debug .bss 16136 16136 0 0.0
.data 242 242 0 0.0
.data.rel.ro 36496 36496 0 0.0
.dynamic 592 592 0 0.0
.got 3528 3528 0 0.0
.init 27 27 0 0.0
.init_array 336 336 0 0.0
.rodata 76463 76463 0 0.0
.text 598242 598242 0 0.0
tv-app debug .bss 216592 216592 0 0.0
.data 2032 2032 0 0.0
.data.rel.ro 57408 57408 0 0.0
.dynamic 592 592 0 0.0
.got 4408 4408 0 0.0
.init 27 27 0 0.0
.init_array 608 608 0 0.0
.rodata 152936 152936 0 0.0
.text 1452994 1452994 0 0.0
bridge-app debug+rpc .bss 52912 52912 0 0.0
.data 976 976 0 0.0
.data.rel.ro 27112 27112 0 0.0
.dynamic 592 592 0 0.0
.got 3952 3952 0 0.0
.init 27 27 0 0.0
.init_array 400 400 0 0.0
.rodata 110748 110748 0 0.0
.text 1063461 1063461 0 0.0
lighting-app debug+rpc .bss 42232 42232 0 0.0
.data 1106 1106 0 0.0
.data.rel.ro 53808 53808 0 0.0
.dynamic 608 608 0 0.0
.got 4112 4112 0 0.0
.init 27 27 0 0.0
.init_array 528 528 0 0.0
.rodata 127921 127921 0 0.0
.text 1261410 1261410 0 0.0
mbed lighting-app CY8CPROTO_062_4343W+release .bss 172100 172100 0 0.0
.data 5464 5464 0 0.0
.heap 858880 858880 0 0.0
.text 1220088 1220088 0 0.0
lock-app CY8CPROTO_062_4343W+release .bss 171020 171020 0 0.0
.data 5432 5432 0 0.0
.heap 859992 859992 0 0.0
.text 1197992 1197992 0 0.0
pigweed-app CY8CPROTO_062_4343W+release .bss 11760 11760 0 0.0
.data 4360 4360 0 0.0
.heap 1020328 1020328 0 0.0
.text 103064 103064 0 0.0
nrfconnect lighting-app nrf52840dk_nrf52840 bss 113180 113180 0 0.0
rodata 98080 98080 0 0.0
text 577104 577104 0 0.0
lock-app nrf52840dk_nrf52840 bss 112244 112244 0 0.0
rodata 94416 94416 0 0.0
text 558592 558592 0 0.0
pigweed-app nrf52840dk_nrf52840 bss 51824 51824 0 0.0
rodata 45776 45776 0 0.0
text 339456 339456 0 0.0
pump-app nrf52840dk_nrf52840 bss 112316 112316 0 0.0
rodata 95396 95396 0 0.0
text 561744 561744 0 0.0
pump-controller-app nrf52840dk_nrf52840 bss 112252 112252 0 0.0
rodata 94476 94476 0 0.0
text 558384 558384 0 0.0
shell nrf52840dk_nrf52840 bss 109072 109072 0 0.0
rodata 72524 72524 0 0.0
text 520208 520208 0 0.0
lighting-app nrf52840dk_nrf52840+rpc bss 109420 109420 0 0.0
rodata 88856 88856 0 0.0
text 550296 550296 0 0.0
nrf5340dk_nrf5340_cpuapp bss 114552 114552 0 0.0
rodata 93320 93320 0 0.0
text 506572 506572 0 0.0
lock-app nrf5340dk_nrf5340_cpuapp bss 113620 113620 0 0.0
rodata 89676 89676 0 0.0
text 488056 488056 0 0.0
shell nrf5340dk_nrf5340_cpuapp bss 110056 110056 0 0.0
rodata 67168 67168 0 0.0
text 440816 440816 0 0.0
p6 lock-app default .bss 68216 68216 0 0.0
.data 2416 2416 0 0.0
.heap 962712 962712 0 0.0
.text 1126688 1126688 0 0.0
qpg lighting-app qpg6100+debug .bss 53464 53464 0 0.0
.data 1004 1004 0 0.0
.text 486036 486036 0 0.0
lock-app qpg6100+debug .bss 52408 52408 0 0.0
.data 960 960 0 0.0
.text 462120 462120 0 0.0
persistent-storage-app qpg6100+debug .bss 27752 27752 0 0.0
.data 372 372 0 0.0
.text 149896 149896 0 0.0
telink lighting-app tlsr9518adk80d bss 71000 71000 0 0.0
noinit 33216 33216 0 0.0
text 457612 457612 0 0.0

@github-actions
Copy link

PR #10297: Size comparison from e282eec to bdc4cad

Increases above 1.0% from e282eec to bdc4cad:

platform target config section e282eec bdc4cad change % change
k32w shell k32w061+debug .bss 55080 63256 8176 14.8
8 builds (for k32w, p6, qpg, telink)
platform target config section e282eec bdc4cad change % change
k32w lock-app k32w061+debug .bss 69068 69228 160 0.2
.data 1864 1864 0 0.0
.text 516024 515092 -932 -0.2
shell k32w061+debug .bss 55080 63256 8176 14.8
.data 672 672 0 0.0
.text 359480 359556 76 0.0
lighting-app k32w061+se05x+release .bss 78592 78744 152 0.2
.data 1900 1900 0 0.0
.text 614788 613792 -996 -0.2
p6 lock-app default .bss 68216 67208 -1008 -1.5
.data 2416 2416 0 0.0
.heap 962712 963720 1008 0.1
.text 1126688 1126008 -680 -0.1
qpg lighting-app qpg6100+debug .bss 53464 52456 -1008 -1.9
.data 1004 1004 0 0.0
.text 486036 485040 -996 -0.2
lock-app qpg6100+debug .bss 52408 51400 -1008 -1.9
.data 960 960 0 0.0
.text 462120 461196 -924 -0.2
persistent-storage-app qpg6100+debug .bss 27752 27752 0 0.0
.data 372 372 0 0.0
.text 149896 149896 0 0.0
telink lighting-app tlsr9518adk80d bss 71000 69988 -1012 -1.4
noinit 33216 33216 0 0.0
text 457612 457674 62 0.0

@woody-apple
Copy link
Contributor

/rebase

@woody-apple
Copy link
Contributor

/rebase

electrocucaracha and others added 2 commits October 23, 2021 01:15
Some of these best practices are:
* Multi-stage builds
* Pin versions
* Avoid additional packages installation
* Clean all missing after apt command

Signed-off-by: Victor Morales <[email protected]>
@woody-apple woody-apple merged commit 2acf3ed into project-chip:master Oct 23, 2021
@electrocucaracha electrocucaracha deleted the improve_mbed_img branch October 25, 2021 16:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants