We're dealing with this same hassle at Slant. For starters, instead of your hello-world build, you can use:
stack build --dependencies-only
We've gone a few steps farther to make Kubernetes deployment easier. We have a base container for web services with this Dockerfile:
FROM haskell:8.2.1 as buildenv
WORKDIR /app
RUN apt-get update && apt-get -y install make xz-utils libpq-dev
RUN stack upgrade --binary-version 1.6.1
RUN stack update && stack setup --resolver lts-11.22
RUN stack build Cabal --resolver lts-11.22
RUN stack build haskell-src-exts --resolver lts-11.22
RUN stack build lens --resolver lts-11.22
RUN stack build aeson --resolver lts-11.22
RUN stack build http-conduit --resolver lts-11.22
RUN stack build servant-server --resolver lts-11.22
We'll occasionally make a new version of this with a bumped LTS version. When we started there was no official 8.4-base docker image, but since we're using stack it doesn't really matter. The explicit install of stack-1.6.1 is due to an error that occurs when trying to pull indexes with 1.7.1 on the kubernetes build server; there's probably a cleaner solution but we're not using any 1.7.1 features yet. Optimally the order here should be "least likely to change goes first" but we haven't done any real analysis on that.
From here, individual services have a Dockerfile roughly like so:
FROM debian:jessie as runtimeenv
RUN apt-get update && apt-get install -y libgmp-dev && rm -rf /var/lib/apt/lists/*
FROM <private>/haskell-webserver:lts-11.22 as dependencies
# pre-build any additional slow local dependencies
COPY stack.yaml .
COPY package.yaml .
COPY submodules ./submodules
RUN rm -rf ~/.stack/indices/
RUN stack build --dependencies-only
FROM dependencies as build
COPY . .
RUN stack build --ghc-options="-O2" # additional options as desired
FROM runtimeenv
WORKDIR /app
COPY --from=build /app/.stack-work/install/x86_64-linux/lts-11.22/8.2.2/bin/app-name-exe .
CMD ./app-name-exe
This gives us a reasonable build speed and nice lean deploy container.