mitchellh / flask-nix-example

Home Page:https://mitchellh.com/writing/nix-with-dockerfiles

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Extra hints for article

superherointj opened this issue · comments

commented

Upsides:

  • Nix can generate containers as small as Alpine, just adding pkgsMusl when building the container.
  • NixNG uses busybox and excludes systemd which reduces image size. Works with Musl. (just import pkgs from pkgsMusl)
  • nix2container doesn't write tarballs to the Nix store and allows to skip already pushed layers (without having to rebuild them).
  • nix-tree (from top-level) to analyze dependencies and size of container.

Downsides (but fixable):

  • Ecosystem immature depending on target.
  • Nixpkgs requires bash (12MB), dash's busybox would take 0MB.
  • Documentation/manuals/auto-completion/assets are still included [shouldn't be].

Sample sizes for containers on my experience:

  • Go ~20MB
  • Elixir's Phoenix 41.7MB
  • Python Flask 181MB (I don't know why Python container is so large.)