Skip to content
This repository was archived by the owner on Feb 15, 2018. It is now read-only.

Optimize image, reduce docker image size by 11GB #13

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

thomasnordquist
Copy link

@thomasnordquist thomasnordquist commented Mar 14, 2017

The changes only consist of structural changes,
the build environment itself has not been altered.

What has been achieved by the changes:

  • much faster build time from 33min to 5.5min (600% faster) (build-time depends on network and IO perfomance)
  • reduces image size from 16.1GB to 5.14GB (>300% smaller)
  • reduces image layers from 52 to 36

Clear /var/lib/apt/lists/ in the same layer apt-get update was invoked:
https://docs.docker.com/engine/userguide/eng-image/dockerfile_best-practices/#run

Optimize for image size:
https://blog.replicated.com/engineering/refactoring-a-dockerfile-for-image-size/

screenshot

This will greatly reduce the final docker image size. (by 678 MB)
This will greatly reduce the final docker image size. (by 2.61GB)
apt-get update is called a few lines below.
This layer won't save any disk space
There are no more packages left, they were cleaned in the layers, they have been downloaded in
The previous usage of `chown` and `chmod` lead to two layers which modified all downloaded files, each layer adding 3.6GB to the docker image. (Total of 7.2 GB)
Build time is now much shorter, since the files won't be copied to a new layer.

Also:
 - Move user creation to top
 - Move environmentals to top
@CLAassistant
Copy link

CLAassistant commented Mar 14, 2017

CLA assistant check
All committers have signed the CLA.

@thomasnordquist
Copy link
Author

travis failed since docker was run with --quiet=true.
It also ran much longer then expected. (Slow CI server ?)

travis_time:start:230c3218
�[0K$ docker build --quiet=true -t uber/android-build-environment .


No output has been received in the last 10m0s, this potentially indicates a stalled build or something wrong with the build itself.
Check the details on how to adjust your build configuration on: https://docs.travis-ci.com/user/common-build-problems/#Build-times-out-because-no-output-was-received

The build has been terminated

alrosot added a commit to alrosot/android-build-environment that referenced this pull request Apr 9, 2017
Copy link

@alrosot alrosot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested on a separate branch

@ottob
Copy link

ottob commented Aug 18, 2017

This seems like an great improvement. Any chance this will be merged?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants