Stack: Docker build consistently runs out of memory

Created on 12 Apr 2018  ·  4Comments  ·  Source: commercialhaskell/stack

General summary/comments (optional)

Steps to reproduce

  1. Add to stack.yaml:
docker:
  enable: true
  1. Run
stack build

Expected

Stack to build project using a docker instance.
Stack to build project in a reasonable timeframe.

Actual

The docker image runs out of memory while GHC is compiling dependencies. The project will eventually finish compiling if you run stack build over and over again--there will be less packages to complete for each invocation. There does not seem to be an obvious way to compile these packages beforehand or to use a binary version which makes the save-compile-test cycle take a very long time on even a modern machine.

$ stack build
[...]
tls-1.4.0: copy/register
vector-0.12.0.1: copy/register
Progress: 93/121
--  While building custom Setup.hs for package Cabal-2.0.1.1 using:
      /Users/dpyro/.stack/setup-exe-cache/x86_64-linux-dkda49f7ca9b244180d3cfb1987cbc9743/Cabal-simple_mPHDZzAJ_2.0.1.0_ghc-8.2.2 --builddir=.stack-work/dist/x86_64-linux-dkda49f7ca9b244180d3cfb1987cbc9743/Cabal-2.0.1.0 build --ghc-options " -ddump-hi -ddump-to-file -fdiagnostics-color=always"
    Process exited with code: ExitFailure (-9) (THIS MAY INDICATE OUT OF MEMORY)
    Logs have been written to: /Users/dpyro/Projects/dexer/.stack-work/logs/Cabal-2.0.1.1.log

    Configuring Cabal-2.0.1.1...
    Preprocessing library for Cabal-2.0.1.1..
    Building library for Cabal-2.0.1.1..
    [  1 of 168] Compiling Distribution.Compat.Binary ( Distribution/Compat/Binary.hs, .stack-work/dist/x86_64-linux-dkda49f7ca9b244180d3cfb1987cbc9743/Cabal-2.0.1.0/build/Distribution/Compat/Binary.o )
    [  2 of 168] Compiling Distribution.Compat.Exception ( Distribution/Compat/Exception.hs, .stack-work/dist/x86_64-linux-dkda49f7ca9b244180d3cfb1987cbc9743/Cabal-2.0.1.0/build/Distribution/Compat/Exception.o )
[...]

Stack version

$ stack --version
Version 1.6.5 x86_64 hpack-0.20.0

Method of installation

  • brew install stack
invalid

Most helpful comment

I had this problem (with docker for mac), and setting the preferences so docker uses more memory fixed it for me.

All 4 comments

How is your Docker Engine configured? If it's running in a VM (e.g. when using Docker Machine or Docker for Mac), have you checked that it has enough memory allocated?

I had this problem (with docker for mac), and setting the preferences so docker uses more memory fixed it for me.

Thanks, @pinguin. I'm going to close, then. @dpyro (or anybody else), do reopen if that doesn't solve your problem.

To solve this, I was initially trying docker run --memory=4g ... but it didn't change anything. I had to go to the docker icon in the top bar (on Mac) and go to "Preferences" and then "Resources", and then slide the slider up to 4gb.

Was this page helpful?
0 / 5 - 0 ratings