docker-images icon indicating copy to clipboard operation
docker-images copied to clipboard

Optimize the size of the images

Open nthiery opened this issue 9 years ago • 7 comments

In theory we should be able to make them smaller than that the current virtual machines (2Gb, which is already huge).

nthiery avatar Jan 29 '16 08:01 nthiery

You are right. I will have a look at Unikernel, which might help us to strip down the OS.

@vbraun How do you create the VM image, do you have some script we could look at? I am not sure what blows up the image that much. From my point of view we are doing everything right. But maybe Sage can somehow strip down its installation by removing unneeded files?

Also, VirtualBox seems to be able to compress its images. In fact, Docker compresses for upload and download, too, but the images seem to be stored uncompressed, I think maybe for speed.

sebasguts avatar Jan 29 '16 10:01 sebasguts

The VM build script is here: https://bitbucket.org/vbraun/sage-virtual-appliance-buildscript

Further possibilities:

  • delete .git
  • delete sources
  • delete documentation doctrees
  • delete logs
  • delete entire documentation if web links are used
  • strip binaries

vbraun avatar Jan 29 '16 10:01 vbraun

@vbraun I'll see about applying that script to the docker images and see if that helps reduce their size.

embray avatar Feb 10 '16 15:02 embray

@vbraun It seems to me that running sage -t -a breaks if the sources are deleted. I think it's good for users to be run at least a portion of the test suite to test their installation, regardless of how it was installed or if the full sources are still available. This is something I'd like to pursue fixing.

You also wrote "strip binaries"--what do you mean in this case?

embray avatar Feb 24 '16 09:02 embray

The .git directory only adds about 21 MB right now, so I might not bother deleting it. Though if you're sure it's not at all useful to have then we could do that--shaving off every little bit helps.

Also, when building the images we apt-get install wget build-essential automake m4 dpkg-dev sudo python libssl-dev git, which adds about 187 MB, but it's not clear that all of those are required at runtime. Obviously some are, like Python. But we could probably uninstall some packages that are no longer needed after build.

embray avatar Feb 24 '16 09:02 embray

  • Deleting unused artifacts should go upstream. I'm pretty sure some of your rm -rf's are already outdated paths on the latest beta
  • System python is a build-time dependency but you don't need it to run Sage
  • Strip binaries: man strip

vbraun avatar Feb 25 '16 09:02 vbraun

Ah okay, that's what I thought you meant just wanted to be sure. For the -develop images we'll want to leave symbols intact for debugging, but for the release images we can do that.

I agree the deletion of unused build artifacts should be improved upstream. In fact I would like to the entire src/ dir be treated as an artifact and improve the test runner so that the tests can be run without src/ (tests in all .py modules should be possible be run out of ./local/lib/python2.7/site-packages/sage; it's been suggested to me that this won't work for tests in Cython modules but I have ideas about that--still need to investigate further).

embray avatar Feb 25 '16 10:02 embray