|
| 1 | +FROM ubuntu:16.04 |
| 2 | + |
| 3 | +MAINTAINER Emanuel Borsboom < [email protected]> |
| 4 | + |
| 5 | +ARG GHC_VERSION=8.6.5 |
| 6 | +ARG LTS_SLUG=lts-13.20 |
| 7 | +ARG PID1_VERSION=0.1.2.0 |
| 8 | +ARG STACK_VERSION=1.9.3 |
| 9 | +ARG CUDA_VERSION=10.0 |
| 10 | +ARG BOOTSTRAP_COMMIT=9f2b7ab95c711794257b059604e80ab9ad3c0c45 |
| 11 | +ARG DEBIAN_FRONTEND=noninteractive |
| 12 | +ARG VARIANT=build |
| 13 | + |
| 14 | +# |
| 15 | +# Set encoding to UTF-8 and PATH to find GHC and cabal/stack-installed binaries. |
| 16 | +# |
| 17 | + |
| 18 | +ENV LANG=C.UTF-8 \ |
| 19 | + LC_ALL=C.UTF-8 \ |
| 20 | + PATH=/root/.cabal/bin:/root/.local/bin:/usr/local/cuda-$CUDA_VERSION/bin:/opt/ghc/$GHC_VERSION/bin:$PATH \ |
| 21 | + CUDA_PATH=/usr/local/cuda-$CUDA_VERSION \ |
| 22 | + LD_LIBRARY_PATH=/usr/local/cuda-$CUDA_VERSION/lib64:/usr/local/cuda-$CUDA_VERSION/nvvm/lib64 |
| 23 | + |
| 24 | +# |
| 25 | +# Use Stackage's debian-bootstrap.sh script to install system libraries and |
| 26 | +# tools required to build any Stackage package. |
| 27 | +# |
| 28 | + |
| 29 | +RUN apt-get update && \ |
| 30 | + apt-get install -y --no-install-recommends wget netbase ca-certificates && \ |
| 31 | + if [ "$VARIANT" = "small" ]; then \ |
| 32 | + echo "deb http://ppa.launchpad.net/hvr/ghc/ubuntu xenial main" >>/etc/apt/sources.list && \ |
| 33 | + echo "deb-src http://ppa.launchpad.net/hvr/ghc/ubuntu xenial main" >>/etc/apt/sources.list && \ |
| 34 | + apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 063DAB2BDC0B3F9FCEBC378BFF3AEACEF6F88286 && \ |
| 35 | + apt-get update && \ |
| 36 | + apt-get install -y --no-install-recommends \ |
| 37 | + ghc-$GHC_VERSION ghc-$GHC_VERSION-htmldocs \ |
| 38 | + g++ gcc libc6-dev libffi-dev libgmp-dev make xz-utils zlib1g-dev git gnupg \ |
| 39 | + libtinfo-dev; \ |
| 40 | + else \ |
| 41 | + wget -qO- https://raw.githubusercontent.com/fpco/stackage/$BOOTSTRAP_COMMIT/debian-bootstrap.sh | sed "s/^GHCVER=8.6.3$/GHCVER=$GHC_VERSION/" | bash && \ |
| 42 | + # Add g++ version required for building 'double-conversion' \ |
| 43 | + # (see https://github.com/commercialhaskell/stack/issues/4470) \ |
| 44 | + apt-get install -y g++-7; \ |
| 45 | + fi && \ |
| 46 | + rm -rf /var/lib/apt/lists/* |
| 47 | + |
| 48 | +# |
| 49 | +# Create symlink to help tools find GHC documentation |
| 50 | +# |
| 51 | + |
| 52 | +RUN ln -s ghc /opt/ghc/$GHC_VERSION/share/doc/ghc-$GHC_VERSION |
| 53 | + |
| 54 | +# |
| 55 | +# Install Stack |
| 56 | +# |
| 57 | + |
| 58 | +RUN wget -qO- https://github.com/commercialhaskell/stack/releases/download/v$STACK_VERSION/stack-$STACK_VERSION-linux-x86_64.tar.gz | tar xz --wildcards --strip-components=1 -C /usr/local/bin '*/stack' |
| 59 | + |
| 60 | +# |
| 61 | +# Configure Stack to use the GHC installed in the Docker image rather than installing its own |
| 62 | +# |
| 63 | + |
| 64 | +RUN mkdir /etc/stack/ && \ |
| 65 | + echo "system-ghc: true" >/etc/stack/config.yaml |
| 66 | + |
| 67 | +# |
| 68 | +# Use 'stack' to install basic Haskell tools like alex, happy, and cpphs. We |
| 69 | +# remove most of the STACK_ROOT afterward to save space, but keep the 'share' |
| 70 | +# files that some of these tools require. |
| 71 | +# |
| 72 | + |
| 73 | +RUN export STACK_ROOT=/usr/local/lib/stack && \ |
| 74 | + stack --resolver=$LTS_SLUG --local-bin-path=/usr/local/bin install \ |
| 75 | + cabal-install happy alex cpphs gtk2hs-buildtools hscolour hlint hindent && \ |
| 76 | + cd $STACK_ROOT && \ |
| 77 | + find . -type f -not -path './snapshots/*/share/*' -exec rm '{}' \; && \ |
| 78 | + find . -type d -print0 |sort -rz |xargs -0 rmdir 2>/dev/null || true |
| 79 | + |
| 80 | +# |
| 81 | +# Install 'pid1' init daemon |
| 82 | +# |
| 83 | + |
| 84 | +RUN wget -O- "https://github.com/fpco/pid1/releases/download/v$PID1_VERSION/pid1-$PID1_VERSION-linux-x86_64.tar.gz" | tar xzf - -C /usr/local && \ |
| 85 | + chown root:root /usr/local/sbin && \ |
| 86 | + chown root:root /usr/local/sbin/pid1 |
| 87 | + |
| 88 | +# |
| 89 | +# Set up pid1 entrypoint and default command |
| 90 | +# |
| 91 | + |
| 92 | +ENTRYPOINT ["/usr/local/sbin/pid1"] |
| 93 | +CMD ["bash"] |
0 commit comments