fabric8io-images / s2i

OpenShift S2I images for Java and Karaf applications
Apache License 2.0
70 stars 84 forks source link

Reduce size of image by remove number of layers #209

Closed vorburger closed 5 years ago

vorburger commented 5 years ago

It may be possible to reduce the size of our images, currently at about 160-ish MB by having less than the 38 layers we have today ?

According to https://opensource.com/article/18/7/building-container-images, it would probably help to concatenate all RUN which we have here and perhaps COPY and ADD into a single one?

According to docker history s2i-java all those layers, except for the yum update && install one are not all that big though, so only a real test would show much that really save.

This https://dustymabe.com/2014/07/07/creating-your-own-minimal-docker-image-in-fedora/ and this https://goldmann.pl/blog/2014/03/06/creating-a-minimal-wildfly-docker-image/ have some other ideas.

vorburger commented 5 years ago

The opensource.com article above also mentions docker build --squash and why that may or may not be a good idea... But that requires dockerd to run with --experimental, which is a PITA. https://github.com/jwilder/docker-squash and https://github.com/goldmann/docker-squash are separate utilities. I wonder if we instead could use buildah for this, see https://github.com/containers/buildah/issues/630 and https://github.com/containers/buildah/pull/714 ...

rhuss commented 5 years ago

Yes, you can use concatenation in the Dockerfile templates to some extent. However because of the way how we modularize with fish-pepper this is not possible in a perfect way. Currenty I don't see a big issue, but lets do what we can for now.