|
| 1 | +FROM debian:10 |
| 2 | +# Based on https://github.com/haskell/docker-haskell/blob/fb5c774c38a7ab2e7d233d95368be0f899353496/8.8/buster/Dockerfile |
| 3 | +# LTS Haskell 16.25 (2020-12-06) GHC 8.8.4 |
| 4 | +# See https://www.stackage.org/lts-16.25 for package versions |
| 5 | + |
| 6 | +ENV LANG=C.UTF-8 |
| 7 | + |
| 8 | +RUN set -ex; \ |
| 9 | + apt-get update; \ |
| 10 | + apt-get install -y --no-install-recommends gnupg ca-certificates dirmngr; \ |
| 11 | + rm -rf /var/lib/apt/lists/*; |
| 12 | + |
| 13 | +ENV GHC=8.8.4 CABAL_INSTALL=3.2 DEBIAN_KEY=427CB69AAC9D00F2A43CAF1CBA3CBA3FFE22B574 LTS_HASKELL=16.25 |
| 14 | +RUN set -ex; \ |
| 15 | + export GNUPGHOME="$(mktemp -d)"; \ |
| 16 | + gpg --batch --keyserver keyserver.ubuntu.com --recv-keys ${DEBIAN_KEY}; \ |
| 17 | + gpg --batch --armor --export ${DEBIAN_KEY} > /etc/apt/trusted.gpg.d/haskell.org.gpg.asc; \ |
| 18 | + gpgconf --kill all; \ |
| 19 | + echo 'deb http://downloads.haskell.org/debian buster main' > /etc/apt/sources.list.d/ghc.list; \ |
| 20 | + apt-get update; \ |
| 21 | + apt-get install -y --no-install-recommends \ |
| 22 | + cabal-install-${CABAL_INSTALL} \ |
| 23 | + curl \ |
| 24 | + g++ \ |
| 25 | + ghc-${GHC} \ |
| 26 | + git \ |
| 27 | + libsqlite3-dev \ |
| 28 | + libtinfo-dev \ |
| 29 | + make \ |
| 30 | + netbase \ |
| 31 | + openssh-client \ |
| 32 | + xz-utils \ |
| 33 | + zlib1g-dev \ |
| 34 | +# regex-pcre requires pcre |
| 35 | + libpcre3 \ |
| 36 | + libpcre3-dev \ |
| 37 | + ; \ |
| 38 | + rm -rf "$GNUPGHOME" /var/lib/apt/lists/* /tmp/* /var/tmp/*; |
| 39 | + |
| 40 | +ENV STACK=2.5.1 STACK_RELEASE_KEY=C5705533DA4F78D8664B5DC0575159689BEFB442 |
| 41 | +RUN set -ex; \ |
| 42 | + export GNUPGHOME="$(mktemp -d)"; \ |
| 43 | + gpg --batch --keyserver keyserver.ubuntu.com --recv-keys ${STACK_RELEASE_KEY}; \ |
| 44 | + curl -fSL https://github.com/commercialhaskell/stack/releases/download/v${STACK}/stack-${STACK}-linux-x86_64.tar.gz -o stack.tar.gz; \ |
| 45 | + curl -fSL https://github.com/commercialhaskell/stack/releases/download/v${STACK}/stack-${STACK}-linux-x86_64.tar.gz.asc -o stack.tar.gz.asc; \ |
| 46 | + gpg --batch --verify stack.tar.gz.asc stack.tar.gz; \ |
| 47 | + gpgconf --kill all; \ |
| 48 | + tar -xf stack.tar.gz -C /usr/local/bin --strip-components=1; \ |
| 49 | + stack config set system-ghc --global true; \ |
| 50 | + stack config set install-ghc --global false; \ |
| 51 | + rm -rf "$GNUPGHOME" /var/lib/apt/lists/* /stack.tar.gz.asc /stack.tar.gz; |
| 52 | + |
| 53 | +ENV PATH=/opt/cabal/${CABAL_INSTALL}/bin:/opt/ghc/${GHC}/bin:$PATH |
| 54 | + |
| 55 | + |
| 56 | +RUN set -ex; \ |
| 57 | + useradd --create-home codewarrior; \ |
| 58 | + mkdir -p /workspace; \ |
| 59 | + chown codewarrior: /workspace; |
| 60 | + |
| 61 | +USER codewarrior |
| 62 | +ENV USER=codewarrior HOME=/home/codewarrior |
| 63 | +ENV PATH=/home/codewarrior/.cabal/bin:/home/codewarrior/.local/bin:$PATH |
| 64 | + |
| 65 | +COPY --chown=codewarrior:codewarrior workspace/ /workspace/ |
| 66 | +WORKDIR /workspace |
| 67 | +RUN stack build |
| 68 | +# Sanity check |
| 69 | +RUN set -ex; \ |
| 70 | + stack ghc -- -O -isrc:test --make -o tests -outputdir /tmp test/Main.hs && ./tests; \ |
| 71 | + rm src/Example.hs test/ExampleSpec.hs tests /tmp/*; |
0 commit comments