|
| 1 | +# ============================================================================= |
| 2 | +# Standalone build of the Haskell toolchain, published as :code-server-haskell |
| 3 | +# |
| 4 | +# Extracted verbatim from the haskell_builder stage of ./Dockerfile so it can be |
| 5 | +# built as its own task, in parallel with the other toolchains, instead of |
| 6 | +# serially inside the main image. The stage remains in ./Dockerfile for now; |
| 7 | +# that copy is retired once this tag exists in the registry. |
| 8 | +# |
| 9 | +# Sets up GHC (compiler), Cabal (package manager), and HLS (language server). |
| 10 | +# ============================================================================= |
| 11 | +FROM ghcr.io/btreemap/dockerfiles:code-server-base AS haskell_builder |
| 12 | + |
| 13 | +# Set environment variables for Haskell installation |
| 14 | +ENV GHCUP_HOME=/opt/ghcup \ |
| 15 | + GHCUP_INSTALL_BASE_PREFIX=$HASKELL_HOME |
| 16 | + |
| 17 | +# Set the working directory for Haskell installation |
| 18 | +WORKDIR $GHCUP_HOME |
| 19 | + |
| 20 | +# Download the appropriate GHCup binary based on architecture |
| 21 | +RUN set -ex && \ |
| 22 | + # Determine target architecture |
| 23 | + ARCH=$(uname -m) && \ |
| 24 | + case "$ARCH" in \ |
| 25 | + x86_64) ARCH=x86_64 ;; \ |
| 26 | + aarch64|arm64) ARCH=aarch64 ;; \ |
| 27 | + *) echo "Unsupported arch: $ARCH" >&2; exit 1 ;; \ |
| 28 | + esac && \ |
| 29 | + # Download GHCup installer |
| 30 | + GHCUP_URL="https://downloads.haskell.org/~ghcup/${ARCH}-linux-ghcup" && \ |
| 31 | + curl -sSL "$GHCUP_URL" -o ghcup && \ |
| 32 | + chmod +x ghcup |
| 33 | + |
| 34 | +# Install GHC, Cabal, and HLS using GHCup |
| 35 | +RUN ./ghcup install ghc --set recommended && \ |
| 36 | + ./ghcup install cabal latest && \ |
| 37 | + ./ghcup install hls latest && \ |
| 38 | + ./ghcup gc --cache --hls-no-ghc --profiling-libs --tmpdirs && \ |
| 39 | + rm -rf \ |
| 40 | + $HASKELL_HOME/.ghcup/cache \ |
| 41 | + $HASKELL_HOME/.ghcup/logs \ |
| 42 | + $HASKELL_HOME/.ghcup/tmp \ |
| 43 | + $HASKELL_HOME/.ghcup/trash |
| 44 | + |
| 45 | +# ============================================================================= |
| 46 | +# Artifact image - carries the installation and nothing else |
| 47 | +# |
| 48 | +# Scratch rather than the builder: this tag exists only to be read by a |
| 49 | +# COPY --from, so republishing all of code-server-base underneath it twice a |
| 50 | +# day would buy nothing. |
| 51 | +# |
| 52 | +# /opt/haskell is code-server-base's $HASKELL_HOME, repeated literally because a |
| 53 | +# scratch stage inherits no ENV. If the two ever diverge this COPY fails the |
| 54 | +# build outright rather than publishing an empty image. $GHCUP_HOME is |
| 55 | +# deliberately not carried: ./Dockerfile copies only $HASKELL_HOME. |
| 56 | +# ============================================================================= |
| 57 | +FROM scratch |
| 58 | + |
| 59 | +COPY --from=haskell_builder /opt/haskell /opt/haskell |
0 commit comments