Skip to content

Reduce image size

Motivation

  1. improve download time in CI
  2. improve disk use (images need to be unpacked after fetching)
  3. improve download time for developers, when fetching images from gitlab registry to reproduce CI failures locally

Suggestions

  1. Merge layers (as few RUN instructions as possible)
  2. omit installing multiple GHCs (e.g. many images install GHC both from repo and bindist... is there a reason?)
  3. possibly delete /opt/toolchain/store after tool installation (is that safe for the binaries?)

Example

  1. registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-alpine3_12:853f348f9caf38b08740b280296fbd34e09abb3a has a compressed size of 1864.45 MB
  2. building the same image locally and pushing it to a local registry results in a compressed size of 1388 MB (I don't know where the 500mb difference comes from... different compression algorithm?)
  3. Merging layers and omitting extraneous repository-based GHC installation I could reduce the size to 869 MB

See the manually modified Dockerfile.

TODO

  • Test deletion of /opt/toolchain/store
  • Provide a PR that fixes the Dhall configuration rather than the generated Dockerfiles