Our team uses Docker to create our Haskell application in it, and to optimize build time, we are working to share the ~/.stack from the OS with one ~/.stack container. The initial implementation was simply to reuse one of the OS, but it turned out that this does not work well, it does not work with this error:
The GHC located at /root/.stack/programs/x86_64-linux/ghc-8.0.1/bin/ghc failed to compile a sanity check. Please see: http://docs.haskellstack.org/en/stable/install_and_upgrade/ for more information. Exception was: Running /root/.stack/programs/x86_64-linux/ghc-8.0.1/bin/ghc /tmp/stack-sanity-check48/Main.hs -no-user-package-db in directory /tmp/stack-sanity-check48/ exited with ExitFailure 127 /root/.stack/programs/x86_64-linux/ghc-8.0.1/bin/ghc: line 9: /home/ubuntu/.stack/programs/x86_64-linux/ghc-8.0.1/lib/ghc-8.0.1/bin/ghc: No such file or directory make: *** [adserver_executables] Error 1
It seems that somewhere in ~/.stack there is a cache that indicates the absolute path to the GHC, and when we mount ~/.stack in the docker, it is set as /root/.stack instead of /home/<user>/.stack , so the compiler canβt follow this path.
Our solution is to create a separate ~/.docker-stack directory, which we will use for all docker builders without interfering with one OS level. This is not ideal, as it will use more space and require recompiling packages, even if they were compiled in an environment that does not support docker level.
Is there a better approach that someone can offer to share ~/.stack with a stack of internal dockers? Thanks.
source share