Sign inSign up

fossa/haskell-static-alpine

By fossa

•Updated 11 months ago

Statically linked distributions of GHC for building binaries in Docker.

Image
0

10K+

fossa/haskell-static-alpine repository overview

See README.md at https://github.com/fossas/haskell-static-alpine⁠, reproduced below.

⁠haskell-static-alpine

haskell-static-alpine is an Alpine-based Docker image that contains GHC and cabal, for building static Haskell executables.

⁠Why do I need this?

Normally, Haskell binaries are dynamically linked, and require glibc and gmp at runtime. These libraries are unavailable in some environments, such as Alpine Docker images.

(Note that even if you specify --enable-executable-static, GHC will still dynamically link against glibc, much like cgo.)

If you deploy Haskell binaries in these environments, you need a fully statically linked executable. You can construct such an executable using this Docker image.

This Docker image uses the Alpine distribution of GHC, which will statically link generated executables against musl when provided --enable-executable-static.

⁠Usage

⁠Pulling the image

This image is automatically published on Docker Hub⁠. To pull it, run:

docker pull fossa/haskell-static-alpine:$VERSION

Supported versions are:

  • ghc-8.8.2
  • ghc-8.10.3
  • ghc-8.10.4
⁠Building your executable

You should use this container as a base image for your own build containers.

Within a container, run:

cabal build --enable-executable-static

This will build a statically linked Haskell binary. Make sure to strip the binary afterwards to reduce size.

Tag summary

Content type

Image

Digest

sha256:eb82a7333…

Size

422.2 MB

Last updated

11 months ago

docker pull fossa/haskell-static-alpine:ghc-9.8.4