estebanmatias92 / docker-hhvm

HHVM base image.
MIT License
7 stars 1 forks source link

Shrink image size #5

Open mikehaertl opened 9 years ago

mikehaertl commented 9 years ago

The RUN apt-get ... step in your Dockerfile now adds enourmous 1.04 GB to the image! My gut feeling tells me, that this can be optimized. It's hard to believe that hhvm really needs all this extra space.

So did you try to install the packages with apt-get install ... --no-install-recommends? And maybe some packages can be removed again after hhvm was compiled (in the same RUN step of course).

mikehaertl commented 9 years ago

I did a quick test with --no-install-recommends and this already saved about 150MB for me. Maybe there's more we could try?

mikehaertl commented 9 years ago

Maybe you could try some of the tricks they do in the official PHP Dockerfile: https://github.com/docker-library/php/blob/1e07e9134490f53d24fbd23ee3521067c8ab2d29/5.6/apache/Dockerfile#L33

estebanmatias92 commented 9 years ago

Thanks for write @mikehaertl.

Sorry for the late answer.

I added the --no-install-recommends tag yesterday to the Dockerfile. To remove the build-time packages after the installation i need to know which are those dependencies (facebook isn't very precise about that).

If i find some resource about that i will can isolate those packages and remove them after. I would be glad with help to shrink the image size, i really want to. The PRs are welcome.

Thanks again.

mikehaertl commented 9 years ago

Hmm, right. It's a trial and error thing probably. So maybe we can define some goals:

If they had a testbed included (which they may?) the former task would be very easy. Just uninstall dependencies until the tests break.

UPDATE: Of course they have a test suite: https://github.com/facebook/hhvm/tree/master/hphp/test. The question then just is, if the test suite itself has maybe the same dependencies again :)

mikehaertl commented 9 years ago

Related: Compiling a statically linked binary would probably allow us to uninstall most of the dependencies without problems. But that seems not to work (yet): https://github.com/facebook/hhvm/issues/4955

estebanmatias92 commented 9 years ago

Thanks @mikehaertl.

I like the idea of trial and error, i was thinking about include some tests for the image (like Docker does) with travis CI to speed up the process, i going work on this.

schmunk42 commented 9 years ago

@estebanmatias92 This link to SO might be useful for setting up Travis + Docker.