<div dir="ltr">I am building Haskell web services using docker. I do this utilising the stack tool within the official Haskell Docker image. Doing this has a number of advantages<div><br></div><div>- It's predictable - I can control bringing in new versions of stack and ghc.</div><div>- It's easy to share - no stack or Haskell installation is required to build the image</div><div>- These services can interact with other services in a controlled environment using Docker compose.</div><div><br></div><div>One downside is that I doing this naively means waiting for a modules to download every time docker build is run since the stack build command will start from scratch each time. I worked around this by adding two build steps. The first runs a hello world example with the stack.yml and package.yml from my project. The second build builds the intended code. This trick separated the downloading of dependent libraries from building the code and means day to day code changes are quick to build since the first stack build is cached as a docker image layer. Still though, making a small change to a stack yml file means a long wait re-downloading all dependent libraries.</div><div><br></div><div>Firstly, is there a better way of doing this? I know stack supports building within docker but when I worked this way I still found projects depended on the system stack and would commonly fail due to stack bugs.</div><div><br></div><div>Secondly, my two "stack build" calls where the first builds a hello world program feels a bit hacky. is there a better way to achieve this?</div><div><br></div><div>Thanks,</div><div>Dan</div><div><br></div><div class="gmail-yj6qo"></div><br class="gmail-Apple-interchange-newline"></div>