[Haskell-cafe] Building stack projects as docker images

tiredpixel tiredpixel at posteo.de
Tue Sep 4 14:47:24 UTC 2018


Dear Dan,

On Tue, 2018-09-04 at 12:21 +0100, Daniel Rolls via Haskell-Cafe wrote:
> 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?

I cannot comment on the Stack parts of your questions, since I don't
currently use it. Regarding the Docker parts, however, have you tried
something like

    COPY [ \
        "cabal.config", \
        "*.cabal", \
        "./"]
    
    RUN cabal update \
        && \
    cabal install -j --only-dependencies

prior to your main compilation layer? That would install the
dependencies once, with the layer cache expiring on change to the lib
declarations, without the need for the 'hello world' program you
describe.

In case you don't freeze your dependencies, you can likely remove the
`cabal.config` line.

Peace,
tiredpixel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: This is a digitally signed message part
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20180904/ed3b7d95/attachment.sig>


More information about the Haskell-Cafe mailing list