docker-coala-base icon indicating copy to clipboard operation
docker-coala-base copied to clipboard

Docker image size is too large

Open yukiisbored opened this issue 8 years ago • 30 comments

The coala/base docker image is pretty large for what it is. The size is 2.63 GB, that's larger than ubuntu and opensuse combined.

There are two ways to solve this:

  • Remove downloaded source code
  • Use another distro (preferably Alpine Linux)

yukiisbored avatar Dec 16 '16 10:12 yukiisbored

So, the size should have be been reduced by clearing the cache 8d9f9ff687015 . It would have been good to have a separate PR for that, with builds before and after that commit so we could see the improvement.

Are there any other changes in the recent changes which might have helped reduce the size?

jayvdb avatar Dec 19 '16 07:12 jayvdb

https://cloud.docker.com/app/coala/repository/docker/coala/base/tags says pre (rebuilt after all this) is still 1Gb, which is what it reports for 0.8 and 0.9 which do not have all the recent attempts at optimising the image size.

jayvdb avatar Dec 19 '16 12:12 jayvdb

Other than using a smaller distro, probably merge some RUN instructions may help increase the amount of layers but that would kill the ease of debugging / diagnostics.

yukiisbored avatar Dec 19 '16 16:12 yukiisbored

Hello, can I be assigned to this issue?

yukiisbored avatar Dec 21 '16 07:12 yukiisbored

Note: We are still waiting for the GCI task to be published.

jayvdb avatar Dec 21 '16 08:12 jayvdb

@jayvdb It's published: https://codein.withgoogle.com/dashboard/task-instances/6600150384377856/

yukiisbored avatar Dec 21 '16 09:12 yukiisbored

https://github.com/coala/docker-coala-base/pull/66 and https://github.com/coala/docker-coala-base/pull/67 removed a few hundred Mb from the image. An image rebuild would be useful.

jayvdb avatar Dec 23 '16 12:12 jayvdb

An analysis build of files > 5Mb

Before any commands are run (including before packages are added):

$ find / -xdev -type f -size +10M
/usr/share/icu/57.1/icudt57l.dat

At the end:

$ find / -xdev -type f -size +10M
/usr/bin/node
/usr/bin/shellcheck
/usr/bin/hlint
/usr/share/go/contrib/src/golang.org/x/tools/.git/objects/pack/pack-e7faa2d81b805c54fc75d515c067e0e5ca57fa82.pack
/usr/share/icu/57.1/icudt57l.dat
/usr/lib/python2.7/site-packages/pyxb/bundles/common/raw/xhtml1.wxs
/usr/lib64/go/pkg/linux_amd64_dynlink/libstd.so
/usr/lib64/jvm/java-1.8.0-openjdk-1.8.0/jre/lib/amd64/server/libjvm.so
/usr/lib64/jvm/java-1.8.0-openjdk-1.8.0/jre/lib/amd64/server/classes.jsa
/usr/lib64/jvm/java-1.8.0-openjdk-1.8.0/jre/lib/rt.jar
/usr/lib64/libopenblas_openmp.so.0
/usr/lib64/julia/sys.so
/usr/lib64/libruby2.2-static.a
/usr/lib64/gcc/x86_64-suse-linux/6/lto1
/usr/lib64/gcc/x86_64-suse-linux/6/libasan.a
/usr/lib64/gcc/x86_64-suse-linux/6/libstdc++.a
/usr/lib64/gcc/x86_64-suse-linux/6/libgfortran.a
/usr/lib64/gcc/x86_64-suse-linux/6/cc1
/usr/lib64/gcc/x86_64-suse-linux/6/cc1plus
/usr/lib64/gcc/x86_64-suse-linux/6/f951
/usr/lib64/libjulia.so.0.5.0
/root/.RLibrary/stringi/libs/icudt55l.dat
/root/.RLibrary/stringi/libs/stringi.so
/root/.RLibrary/igraph/libs/igraph.so
/root/pmd-bin-5.4.1/lib/scala-compiler-2.10.4.jar
/root/nltk_data/tokenizers/punkt.zip
/root/.julia/v0.5/METADATA/.git/objects/pack/pack-ae7cd04fc8509df91bd5b36ee8d9104e3bb8bf4a.pack
/root/.bundle/cache/compact_index/rubygems.org.443.29b0360b937aa4d161703e6160654e47/versions
/var/lib/rpm/Packages
/coala/.git/objects/pack/pack-708ef23f4cf60fb7b7436b1a3031701e5648b015.pack

Some of those files are not necessary.

jayvdb avatar Jan 02 '17 09:01 jayvdb

I've added another task for this, which is simpler and can be used to find smaller size reductions, which are still useful.

An example of that task is removing R-core-doc

jayvdb avatar Jan 02 '17 09:01 jayvdb

R-recommended-packages seems to be unnecessary. https://github.com/rhemon/docker-coala-base/commit/ff853d71c0e36db87e5efb5be2a1fae214480bd6 https://travis-ci.org/rhemon/docker-coala-base/builds/189255334

rhemon avatar Jan 05 '17 18:01 rhemon

@rhemon it still pulls R-recommended-packages because it's a dependency for one of the R packages

yukiisbored avatar Jan 05 '17 18:01 yukiisbored

yeah sorry @jayvdb explained me about it

rhemon avatar Jan 05 '17 18:01 rhemon

libasan3 seems to be unnecessary (although it only reduces size by 0.001 GB) https://travis-ci.org/rhemon/docker-coala-base/builds/189275655 https://github.com/rhemon/docker-coala-base/commit/b75ae0376db9b242af4630b27a1177badfe7f35b

rhemon avatar Jan 05 '17 19:01 rhemon

Found these unnecessary packages and erased them in PR https://github.com/coala/docker-coala-base/pull/80 :

libasan3
python3-six
python-cssselect
python-curses
python-javapackages 
python-lxml 
python-Pygments 
python-pyxb 
python-setuptools 
python-six 
python-xml 
texlive-gsftopk 
texlive-kpathsea 
xorg-x11-fonts
xorg-x11-fonts-core 

rhemon avatar Jan 06 '17 18:01 rhemon

Found that postfix was unnecessary and also thanks for @jayvdb for mentioning R-core-doc The travis build: https://travis-ci.org/GnarledHarpy06/docker-coala-base/builds/191619054

giovanism avatar Jan 13 '17 13:01 giovanism

btw https://github.com/coala/docker-coala-base/issues/84#issuecomment-272386925 was another set of 9 unnecessary packages, trimming 3 MB from the image.

jayvdb avatar Jan 14 '17 12:01 jayvdb

Remove more unnecessary packages here https://github.com/coala/docker-coala-base/pull/86

aaa_base
dbus-1
dbus-1-x11
gio-branding-openSUSE
kmod
libthai-data
lksctp-tools
logrotate
openssh
openslp
perl-Net-DBus
postfix
R-core-doc
sysconfig-netconfig
systemd-presets-branding-openSUSE
wicked-service

giovanism avatar Jan 14 '17 15:01 giovanism

Current status: 2.514 GB

jayvdb avatar Feb 19 '17 09:02 jayvdb

Current status: 2.386 GB

jayvdb avatar Feb 20 '17 04:02 jayvdb

https://github.com/rancher/dapper is a tool to wrap any existing build tool in an consistent environment. It could reduce the size of images significantly but I'm not sure if it's suitable for coala.

I will have a try.

gaocegege avatar Feb 22 '17 08:02 gaocegege

Current: 2.306 GB

jayvdb avatar Feb 22 '17 18:02 jayvdb

Now 2.206 GB

jayvdb avatar Feb 23 '17 11:02 jayvdb

After a few fixes and additions, the current size has only increased slightly to 2.208 GB

jayvdb avatar Mar 23 '17 01:03 jayvdb

As an experiment, I tried to make the installation of lua-devel and luarocks temporary. The result is the image increases by 33Mb from 2.208 GB to 2.241 GB. See commit and build. This is counter intuitive, and suggests there are extra steps needed to completely tidy up after using zypper.

Update: jayvdb/docker-coala-base@d628dd8 build is slightly better, but with the same result.

jayvdb avatar Mar 23 '17 02:03 jayvdb

master is down to 2.195 GB

jayvdb avatar Mar 25 '17 06:03 jayvdb

This post is a WIP cataloging some a bunch of my tiny un-PR'd stuff

On the other hand

-use-phpsniffer-package - adds 5mb

jayvdb avatar Mar 25 '17 11:03 jayvdb

After removing some X libs, down to 2.188 Gb

jayvdb avatar Mar 30 '17 05:03 jayvdb

Due to voodoo behind the scenes in openSUSE, the image size is down to 2.143 GB (after https://github.com/coala/docker-coala-base/pull/158 which doesnt affect size)

jayvdb avatar Apr 16 '17 11:04 jayvdb

After https://github.com/coala/docker-coala-base/pull/185 , we're back up to 2.222 GB

EDIT: And after https://github.com/coala/docker-coala-base/pull/188 , 2.23 GB

jayvdb avatar Jun 19 '17 00:06 jayvdb

After https://github.com/coala/docker-coala-base/pull/241 , the size is back down to 2.2Gb

jayvdb avatar Aug 06 '17 23:08 jayvdb