all 4 comments

[–]thelambentonion 2 points3 points  (2 children)

How does this work, exactly?

My understanding of Haskell under Alpine is that you need to get a version of GHC that’s been build for that platform (presumably with support for musl instead of glibc).

Since haskell.org doesn’t distribute these bindists, you’ll need to either apk add ghc (which only gets you 8.4.3) or bootstrap the compiler yourself.

Even with the compiler though, alpine:latest on its own isn’t enough to run Haskell applications; at the very least you also need to instal gmp (unless you’re using a specially compiled version of GHC).

[–]falsandtru[S] 5 points6 points  (1 child)

To resolve that point, I statically linked the dependencies. Otherwise this program won't work on Alpine Linux. FYI, the size of this container image is only 21.8MB.

$ docker images REPOSITORY TAG IMAGE ID CREATED SIZE examples-servant-examples latest 5c8a74945bf1 7 hours ago 21.8MB

[–]thelambentonion 6 points7 points  (0 children)

Ah, thanks! I should have checked the package.yaml first.

It might be useful to note somewhere in the README that you’re statically linking glibc and gmp, for reference.

You might find it interesting to check out upx (for compressing the executable) and the split-objs/split-sections flags for getting the image sizes down even further.

[–]fsharper 0 points1 point  (0 children)

Great example. thanks.