Create docker

20 views
Skip to first unread message

Corentin Dupont

unread,
Feb 11, 2019, 9:04:27 AM2/11/19
to haskell-stack
Hi,
I'm trying to create a docker container for my application (to deploy it on Amazon ECS).
However, the images generated are huge: from 4 Go to 7Go.

Any feedback on experience with Haskell in Docker? My feeling is that Haskellers doesn't use it too much... Am I wrong?

Corentin

Michael Snoyman

unread,
Feb 11, 2019, 10:22:49 AM2/11/19
to Corentin Dupont, haskell-stack
I use Docker extensively in Haskell projects, both for builds and deployments. We do this for most work at FP Complete as well, and most of our clients do too. The issue you're running into is that you're using a Haskell _build_ image (which includes GHC and other build tools) for creating a runtime image. My recommendation: based your deployment on a much more lightweight image. You can start off with Ubuntu, for example, or fpco/pid1:18.04 (which includes a more intelligent pid-1 process). Some people will argue that you should try to use something more minimal, and/or try to do static linking. I think starting off with Ubuntu is perfectly reasonable.

Some relevant blog posts:


--
You received this message because you are subscribed to the Google Groups "haskell-stack" group.
To unsubscribe from this group and stop receiving emails from it, send an email to haskell-stac...@googlegroups.com.
To post to this group, send email to haskel...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/haskell-stack/CAEyhvmpdVTqiCHTzf8MkAzit2WOPdz36sZmtU-FLQ6HSm1jT%2Bw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Corentin Dupont

unread,
Feb 11, 2019, 11:21:05 AM2/11/19
to Michael Snoyman, haskell-stack
Hi Michael,
thanks for the reply.
I'm trying to create Dockerfiles for reproducible builds. I have a platform with components written in various languages, so I don't expect users to install all build tools to compile... So I strive to provide Dockerfiles that manage both compilation and deployment.
Maybe it's a misunderstanding on my side to try to get both compilation and deployement in the same Dockerfile?
Thanks a lot.

Corentin Dupont

unread,
Feb 11, 2019, 11:27:35 AM2/11/19
to Michael Snoyman, haskell-stack
I just found out I could use multi-stage builds to solve my problem: https://docs.docker.com/develop/develop-images/multistage-build/
The idea is to use the command "FROM" again after building...
Reply all
Reply to author
Forward
0 new messages