-
-
Save hasufell/f0893abfbba63ac4ea40feb0520946ee to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM alpine:3.11 as hs | |
# install ghc and stack | |
RUN \ | |
apk add --no-cache git curl gcc g++ gmp-dev ncurses-dev libffi-dev make xz tar perl && \ | |
apk add --no-cache zlib zlib-dev zlib-static ncurses-static && \ | |
curl https://downloads.haskell.org/~ghcup/x86_64-linux-ghcup > /usr/bin/ghcup && \ | |
chmod +x /usr/bin/ghcup && \ | |
ghcup install ghc 8.6.5 && \ | |
ghcup set ghc 8.6.5 && \ | |
ghcup install stack | |
# install haskell-code-explorer | |
RUN \ | |
git clone https://github.com/alexwl/haskell-code-explorer.git ~/haskell-code-explorer && \ | |
cd ~/haskell-code-explorer && \ | |
export PATH="/root/.ghcup/bin:$PATH" && \ | |
stack --system-ghc --stack-yaml=stack-8.6.5.yaml install --ghc-options='-optl-static -split-sections' --copy-bins | |
FROM ubuntu:bionic | |
RUN \ | |
apt-get update && \ | |
apt-get -y upgrade && \ | |
apt-get install -y software-properties-common && \ | |
apt-get install -y curl git wget nano && \ | |
apt-get install -y build-essential pkg-config curl libffi-dev libffi6 libgmp-dev libgmp10 libncurses-dev libncurses5 libtinfo5 && \ | |
apt-get install -y libsodium-dev sqlite zlib1g-dev libssl-dev && \ | |
rm -rf /var/lib/apt/lists/* | |
COPY --from=hs /usr/bin/stack /usr/bin/stack | |
COPY --from=hs /usr/bin/ghcup /usr/bin/ghcup | |
COPY --from=hs /root/.local/bin/haskell-code-server /usr/bin/haskell-code-server | |
COPY --from=hs /root/.local/bin/haskell-code-indexer /usr/bin/haskell-code-indexer | |
I see. I ended up doing just stack --system-ghc install --copy-bins
without the --ghc-options
flag. I think it solved the issue I was having with the built binary not working in another container based on another OS. Anyways, this example was helpful, especially the ghcup install part! Thanks.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ghc-options cause the binary to be linked statically. Then you can copy anywhere. For that to work you need to use alpine container though (or some other musl based one).