
Hi Mark, That would be great, and I have tried that, but there is one issue that caused me to take the current approach instead. The issue is that every change to * Setup.hs * simple-app.cabal * stack.yaml will cause the docker to consider the copy statement
COPY LICENSE Setup.hs simple-app.cabal stack.yaml /app/
as a fresh checkpoint, and make the cache unusable. Since I've frequently
changing stack.yaml, and app.cabal, this won't help me much.
Not sure if there's a way around that with this method.
Let me know if I've overlooked something with your approach!
- Lyndon
On Thu, Feb 25, 2016 at 9:04 AM, Mark Fine
You can ask stack to build only dependencies and use that as a cache layer for docker. We do something like:
FROM haskell:7.10
WORKDIR /app
COPY LICENSE Setup.hs simple-app.cabal stack.yaml /app/ RUN stack setup RUN stack build simple-app --only-dependencies
COPY main /app/main COPY src /app/src RUN stack build simple-app --copy-bins
On Wed, Feb 24, 2016 at 1:07 PM, Lyndon Maydwell
wrote: Hi Beginners,
I'm finally getting my hands dirty with Stack, and am using it in conjunction with Docker, but not with the built-in docker functionality.
My Dockerfile is constructed so that it first installs a whole bunch of dependencies globally, like so:
... RUN stack install HUnit ...
Then after that, installs the project:
... COPY . /app WORKDIR /app RUN stack install ...
This means that on repeated docker builds the app build and install time should be limited to just the application itself, because the dependency builds were cached. Which is great! However, I'm currently generating the list of dependencies just by looking at the output of the stack build of the app, and this displays everything as a flat list.
I'd like to see some kind of tree instead, so that when I pre-install the dependencies, I can specify a minimal list, rather than a whole slew of dependencies that would be pulled in transitively anyway.
Is there an easy way to do this?
Regards,
- Lyndon
_______________________________________________ Beginners mailing list Beginners@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
_______________________________________________ Beginners mailing list Beginners@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners