How to reduce Docker image size for Rails and Elixir

ruby

#1

Hello,
we are actually using multi-stage Dockerfiles to reduce the size of images (something similar to this https://github.com/ledermann/docker-rails/blob/develop/Dockerfile ). For example on Rails we don’t need nodejs after the assets are compiled.

Is there a way we can obtain a similar build pattern with Habitat?


#2

The current Docker exporter doesn’t do anything with multi-stage Dockerfiles. That being said, it only includes the Supervisor, the service you’re exporting, and all its runtime dependencies, so there’s not much at all in the way of unnecessary extras being baked into the image.

You may be interested in https://github.com/habitat-sh/habitat/issues/5589, though.


#3

@christophermaier is correct. Make sure node is in your pkg_build_deps and it won’t be included in the resulting container