`hab pkg export docker` images are large

It seems that the docker images are largeish at least 500mb or more. I compared my habitat-ized Tomcat with the docker hub’s Tomcat:

bdangit/tomcat   8.0.36-20160726172516   592.7 MB

vs.

tomcat           8.0.36-jre8-alpine      134.6 MB

Am I building my docker containers wrong?

No, you aren’t building them wrong. The major difference is the choice of libc - alpine uses musl, which is significantly smaller than glibc, at the cost of ease of compilation for the common case. A closer comparable would be tomcat:8.0.36-jre8, which uses glibc. That image comes in at 336MB.

Looking at your deps, you depend on both ant and jdk8. Most likely you don’t need the jdk, but instead the jre - it looks like nobody has packaged the JRE yet. You probably don’t need ant, either.

Cheers,
Adam

Thanks @adam! You are right. I did the suggestions you stated; and was able to get a binary that is 361.4MB (slightly larger by 30MB but getting closer).

I moved the ant and jdk as build dependencies as they are required for building tomcat from source. Actual dependencies is blank. In order to get jre, core/jdk8 includes the jre directory so I moved that into my packaging. But I have other issues, where I am able to run hab start bdangit/tomcat inside the studio and it will work; however outside in docker it won’t work as it appears I’m missing some of the shared libraries.

tomcat(O): /hab/pkgs/bdangit/tomcat/8.0.36/20160726221441/jre/bin/java: error while loading shared libraries: libjli.so: cannot open shared object file: No such file or directory

Sounds like I’ll just have to make a hab package for jre.