Reduce image size
Motivation
- improve download time in CI
- improve disk use (images need to be unpacked after fetching)
- improve download time for developers, when fetching images from gitlab registry to reproduce CI failures locally
Suggestions
- Merge layers (as few
RUN
instructions as possible) - omit installing multiple GHCs (e.g. many images install GHC both from repo and bindist... is there a reason?)
- possibly delete
/opt/toolchain/store
after tool installation (is that safe for the binaries?)
Example
-
registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-alpine3_12:853f348f9caf38b08740b280296fbd34e09abb3a
has a compressed size of1864.45 MB
- 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?) - 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