与docker共享〜/ .stack

Kos*_*kov 7 haskell haskell-stack

我们的团队正在使用Docker构建我们的Haskell应用程序,为了优化构建时间,我们努力将~/.stack操作系统中的目录与docker容器内的目录共享.最初的实现只是重用OS中的那个,但事实证明这不能很好地工作,它失败并出现如下错误:

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
Run Code Online (Sandbox Code Playgroud)

似乎某个地方~/.stack有一个缓存~/.stack,它指明了GHC的绝对路径,当我们在docker中挂载时,它会被挂载/root/.stack而不是/home/<user>/.stack,因此该路径找不到编译器.

我们目前的决定是创建一个单独的目录~/.docker-stack,我们将用于所有基于docker的构建,而不会干扰操作系统级别的目录.这并不理想,因为它将占用更多空间,并且即使在非docker OS级环境中编译它们也需要重新编译包.

是否有更好的方法有人可以建议~/.stack与内部Docker堆栈共享?谢谢.