Doichain / dapp

Doichan dApp - a Meteor.js implementation of the "Doichain Atomic Double-Opt-In" Protocol
https://www.doichain.org
MIT License
6 stars 6 forks source link

Analysis: Docker image size reduction #139

Open silkroadnomad opened 4 years ago

silkroadnomad commented 4 years ago

The Doichain/dApp docker image seems far to big. An analyzes needs to be investigated what are the things which make it so big and how could we reduce it later on. Please provide your suggestions in the Github Issue.

jay-dee7 commented 4 years ago

hey @inspiraluna, my initial analysis is:

  1. we're trying to do too many tasks inside a single image (we can split it to fasten the build time)
  2. node:12 as base is 340 MB, maybe we can go with an alpine or slim version which would only have a base image size around 30-40MB
  3. We have too many RUN clauses, which leads to multitude of docker layers inside the image and doesn't work well with caching. if we can somehow combine multiple RUN clauses into a single or maybe two, it'll help.
  4. we can also remove the compile time dependencies after the build is done (few are already being removed).

I'll post a dive analysis of the image later on, which will help us understand it much better

jay-dee7 commented 4 years ago

@inspiraluna i've analyzed the docker image. Here are the findings:

  1. RUN statement from line 9 of base.Dockerfile leads upto: 1.5 GB, these all are either dev tools (vim, jq, bc, git) or compile utils (build-essentials,apt-utils and other libs), we should remove these after compiling the meteor app.
  2. RUN statement on line 62 of base.Dockerfile leads upto a whopping 2.8GB, i'm sure we can do something around here to make it all light.
  3. Finally, RUN clause of main Dockerfile, line 78 sums upto 1.3 GB of size, here we have very little to improve i believe.

The final decompressed image is 6.7GB and size on docker hub is 1.7GB (compressed).

I think we we focus our efforts into these 3 checkpoints, we should be able to reduce the size of our image by a significant factor

jay-dee7 commented 4 years ago

Hey @inspiraluna, i believe the above mentioned analysis should be enough to get us started and cut the size of the image by at least 30-40%. Please let me know if you have any inputs