|
| 1 | +FROM alpine:3.15 |
| 2 | + |
| 3 | +RUN apk add --no-cache \ |
| 4 | + ca-certificates \ |
| 5 | + curl \ |
| 6 | + gcc \ |
| 7 | + git \ |
| 8 | + g++ \ |
| 9 | + gmp-dev \ |
| 10 | + gnupg \ |
| 11 | + make \ |
| 12 | + musl-dev \ |
| 13 | + ncurses-dev \ |
| 14 | + libc-dev \ |
| 15 | + libffi-dev |
| 16 | + |
| 17 | +ARG STACK=2.9.1 |
| 18 | +ARG STACK_RELEASE_KEY=C5705533DA4F78D8664B5DC0575159689BEFB442 |
| 19 | + |
| 20 | +RUN set -eux; \ |
| 21 | + cd /tmp; \ |
| 22 | + ARCH="$(apk --print-arch)"; \ |
| 23 | + STACK_URL="https://github.com/commercialhaskell/stack/releases/download/v${STACK}/stack-${STACK}-linux-$ARCH.tar.gz"; \ |
| 24 | + # sha256 from https://github.com/commercialhaskell/stack/releases/download/v${STACK}/stack-${STACK}-linux-$ARCH.tar.gz.sha256 |
| 25 | + case "$ARCH" in \ |
| 26 | + 'x86_64') \ |
| 27 | + STACK_SHA256='0581cebe880b8ed47556ee73d8bbb9d602b5b82e38f89f6aa53acaec37e7760d'; \ |
| 28 | + ;; \ |
| 29 | + *) echo >&2 "error: unsupported architecture '$ARCH'" ; exit 1 ;; \ |
| 30 | + esac; \ |
| 31 | + curl -sSL "$STACK_URL" -o stack.tar.gz; \ |
| 32 | + echo "$STACK_SHA256 stack.tar.gz" | sha256sum -c; \ |
| 33 | + \ |
| 34 | + curl -sSL "$STACK_URL.asc" -o stack.tar.gz.asc; \ |
| 35 | + GNUPGHOME="$(mktemp -d)"; export GNUPGHOME; \ |
| 36 | + gpg --batch --keyserver keyserver.ubuntu.com --receive-keys "$STACK_RELEASE_KEY"; \ |
| 37 | + gpg --batch --verify stack.tar.gz.asc stack.tar.gz; \ |
| 38 | + gpgconf --kill all; \ |
| 39 | + \ |
| 40 | + tar -xf stack.tar.gz -C /usr/local/bin --strip-components=1 "stack-$STACK-linux-$ARCH/stack"; \ |
| 41 | + stack config set system-ghc --global true; \ |
| 42 | + stack config set install-ghc --global false; \ |
| 43 | + \ |
| 44 | + rm -rf /tmp/*; \ |
| 45 | + \ |
| 46 | + stack --version; |
| 47 | + |
| 48 | +ARG CABAL_INSTALL=3.8.1.0 |
| 49 | +ARG CABAL_INSTALL_RELEASE_KEY=E9EC5616017C3EE26B33468CCE1ED8AE0B011D8C |
| 50 | + |
| 51 | +RUN set -eux; \ |
| 52 | + cd /tmp; \ |
| 53 | + ARCH="$(apk --print-arch)"; \ |
| 54 | + CABAL_INSTALL_TAR="cabal-install-$CABAL_INSTALL-$ARCH-linux-alpine.tar.xz"; \ |
| 55 | + CABAL_INSTALL_URL="https://downloads.haskell.org/~cabal/cabal-install-$CABAL_INSTALL/$CABAL_INSTALL_TAR"; \ |
| 56 | + CABAL_INSTALL_SHA256SUMS_URL="https://downloads.haskell.org/~cabal/cabal-install-$CABAL_INSTALL/SHA256SUMS"; \ |
| 57 | + # sha256 from https://downloads.haskell.org/~cabal/cabal-install-$CABAL_INSTALL/SHA256SUMS |
| 58 | + case "$ARCH" in \ |
| 59 | + 'x86_64') \ |
| 60 | + CABAL_INSTALL_SHA256='4c5626115ca8d3eaba0f6a79a364952a2403a03a459dd6e247a96546cdd50836'; \ |
| 61 | + ;; \ |
| 62 | + *) echo >&2 "error: unsupported architecture '$ARCH'"; exit 1 ;; \ |
| 63 | + esac; \ |
| 64 | + curl -sSL "$CABAL_INSTALL_URL" -o cabal-install.tar.gz; \ |
| 65 | + echo "$CABAL_INSTALL_SHA256 cabal-install.tar.gz" | sha256sum -c; \ |
| 66 | + \ |
| 67 | + curl -sSLO "$CABAL_INSTALL_SHA256SUMS_URL"; \ |
| 68 | + curl -sSLO "$CABAL_INSTALL_SHA256SUMS_URL.sig"; \ |
| 69 | + GNUPGHOME="$(mktemp -d)"; export GNUPGHOME; \ |
| 70 | + gpg --batch --keyserver keyserver.ubuntu.com --receive-keys "$CABAL_INSTALL_RELEASE_KEY"; \ |
| 71 | + gpg --batch --verify SHA256SUMS.sig SHA256SUMS; \ |
| 72 | + # confirm we are verying SHA256SUMS that matches the release + sha256 |
| 73 | + grep "$CABAL_INSTALL_SHA256 $CABAL_INSTALL_TAR" SHA256SUMS; \ |
| 74 | + gpgconf --kill all; \ |
| 75 | + \ |
| 76 | + # seems this is not gzip compression |
| 77 | + tar --lzma -xvpf cabal-install.tar.gz -C /usr/local/bin; \ |
| 78 | + \ |
| 79 | + rm -rf /tmp/*; \ |
| 80 | + \ |
| 81 | + cabal --version |
| 82 | + |
| 83 | +ARG GHC=9.0.2 |
| 84 | +ARG GHC_RELEASE_KEY=88B57FCF7DB53B4DB3BFA4B1588764FBE22D19C4 |
| 85 | + |
| 86 | +RUN set -eux; \ |
| 87 | + cd /tmp; \ |
| 88 | + ARCH="$(apk --print-arch)"; \ |
| 89 | + GHC_URL="https://downloads.haskell.org/~ghc/$GHC/ghc-$GHC-$ARCH-alpine3.12-linux-gmp.tar.xz"; \ |
| 90 | + # sha256 from https://downloads.haskell.org/~ghc/$GHC/SHA256SUMS |
| 91 | + case "$ARCH" in \ |
| 92 | + 'x86_64') \ |
| 93 | + GHC_SHA256='5bb1e7192c2b9fcff68930dbdc65509d345138e9a43c5d447056a68decc05ec8'; \ |
| 94 | + ;; \ |
| 95 | + *) echo >&2 "error: unsupported architecture '$ARCH'" ; exit 1 ;; \ |
| 96 | + esac; \ |
| 97 | + curl -sSL "$GHC_URL" -o ghc.tar.xz; \ |
| 98 | + echo "$GHC_SHA256 ghc.tar.xz" | sha256sum -c; \ |
| 99 | + \ |
| 100 | + GNUPGHOME="$(mktemp -d)"; export GNUPGHOME; \ |
| 101 | + curl -sSL "$GHC_URL.sig" -o ghc.tar.xz.sig; \ |
| 102 | + gpg --batch --keyserver keyserver.ubuntu.com --receive-keys "$GHC_RELEASE_KEY"; \ |
| 103 | + gpg --batch --verify ghc.tar.xz.sig ghc.tar.xz; \ |
| 104 | + gpgconf --kill all; \ |
| 105 | + \ |
| 106 | + tar xf ghc.tar.xz; \ |
| 107 | + cd "ghc-$GHC-$ARCH-unknown-linux"; \ |
| 108 | + ./configure --prefix "/opt/ghc/$GHC" --disable-ld-override; \ |
| 109 | + make install; \ |
| 110 | + # remove some docs |
| 111 | + rm -rf "/opt/ghc/$GHC/share/"; \ |
| 112 | + \ |
| 113 | + rm -rf /tmp/*; \ |
| 114 | + \ |
| 115 | + "/opt/ghc/$GHC/bin/ghc" --version |
| 116 | + |
| 117 | +ENV PATH /root/.cabal/bin:/root/.local/bin:/opt/ghc/${GHC}/bin:$PATH |
| 118 | + |
| 119 | +CMD ["ghci"] |
0 commit comments