diff --git a/.devcontainer/VERSION_MATRIX.md b/.devcontainer/VERSION_MATRIX.md
index de03706f3cd60ecb5dd7fdcad530b1e2552047bd..b918eb3a474dec992bd36f01ec66bca3c7dad07f 100644
--- a/.devcontainer/VERSION_MATRIX.md
+++ b/.devcontainer/VERSION_MATRIX.md
@@ -5,7 +5,8 @@
 | GHC                         | Cabal[^1] | Stack[^1]   | HLS                                                            |
 |:----------------------------|:----------|:------------|:-------------------------------------------------------------- |
 | latest<br>9.8.1<br>9.8<br>9 | 3.10.2.1  | ≥ 2.13.1    | latest<br>2.5.0.0                                              |
-| 9.6.3<br>9.6                | 3.10.1.0  | ≥ 2.13.1    | 2.5.0.0<br>2.4.0.0<br>2.3.0.0<br>2.2.0.0                       |
+| 9.6.4<br>9.6                | 3.10.1.0  | ≥ 2.13.1    | n/a                                                       |
+| 9.6.3                       | 3.10.1.0  | ≥ 2.13.1    | 2.5.0.0<br>2.4.0.0<br>2.3.0.0<br>2.2.0.0                       |
 | 9.4.8<br>9.4                | 3.8.1.0   | ≥ 2.13.1    | 2.5.0.0<br>2.4.0.0                                             |
 | 9.4.7                       | 3.8.1.0   | ≥ 2.13.1    | 2.4.0.0<br>2.3.0.0<br>2.2.0.0<br>2.1.0.0<br>2.0.0.1            |
 | 9.2.8<br>9.2                | 3.6.2.0   | ≥ 2.13.1    | 2.5.0.0<br>2.4.0.0<br>2.3.0.0<br>2.2.0.0<br>2.1.0.0<br>2.0.0.1 |
diff --git a/.devcontainer/ghc-9.6/devcontainer.json b/.devcontainer/ghc-9.6/devcontainer.json
index 02cd3957bd30bfeffb5e3b77f6915badcba33448..b4f3ca9a1dddaf2f442282631ed62a95b303864d 100644
--- a/.devcontainer/ghc-9.6/devcontainer.json
+++ b/.devcontainer/ghc-9.6/devcontainer.json
@@ -5,7 +5,7 @@
     "context": "..",
     "args": {
       "GHC_VERSION": "9.6",
-      "HLS_VERSION": "2.5.0.0",
+      // "HLS_VERSION": "2.5.0.0",
       "USE_ZSH_FOR_ROOT": "unset-to-use-ash",
       "SET_LANG": "C.UTF-8",
       "SET_TZ": ""
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index c98d01745086baa96cf69f30dd1392718afeab39..66ec227351b91c079d9dad10e31c928919596103 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -1,7 +1,7 @@
 .env:
   variables:
-    GHC_VERSION: "9.8.1"
-    CABAL_VERSION: "3.10.2.1"
+    GHC_VERSION: "9.6.4"
+    CABAL_VERSION: "3.10.1.0"
     STACK_VERSION: "2.13.1"
     HLS_VERSION: "2.5.0.0"
     BUILD_GHC: "true"
diff --git a/VERSION_MATRIX.md b/VERSION_MATRIX.md
index b0cbad2e37677ebaf1af3497a81bc65876584b2f..09907ade9f4f67f172baff919b6e62e33e27d0d2 100644
--- a/VERSION_MATRIX.md
+++ b/VERSION_MATRIX.md
@@ -5,10 +5,11 @@ Topmost entry = Tag `latest`
 | GHC        | Cabal    | Stack      | LLVM | Linux distro |
 |:-----------|:---------|:-----------|:---- |:-------------|
 | 9.8.1      | 3.10.2.1 | 2.13.1     | 14   | Alpine 3.18  |
-| 9.6.3      | 3.10.1.0 | 2.13.1     | 14   | Alpine 3.18  |
+| 9.6.4      | 3.10.1.0 | 2.13.1     | 14   | Alpine 3.19  |
+| 9.6.3      | 3.10.1.0 | 2.13.1     | 14   | Alpine 3.19  |
 | 9.6.2      | 3.10.1.0 | 2.11.1[^1] | 14   | Alpine 3.18  |
 | 9.6.1      | 3.10.1.0 | n/a        | 14   | Alpine 3.18  |
-| 9.4.8      | 3.8.1.0  | 2.13.1     | 14   | Alpine 3.18  |
+| 9.4.8      | 3.8.1.0  | 2.13.1     | 14   | Alpine 3.19  |
 | 9.4.7      | 3.8.1.0  | 2.13.1     | 14   | Alpine 3.18  |
 | 9.4.6      | 3.8.1.0  | 2.11.1[^1] | 14   | Alpine 3.18  |
 | 9.4.5      | 3.8.1.0  | n/a        | 14   | Alpine 3.17  |
diff --git a/packages/hls/2.5.0.0.Dockerfile b/packages/hls/2.5.0.0.Dockerfile
index 2f93a2de47601177e3b186960dfb0a9aea4deec1..f83a464c1d1bd46a402549a76ac3fa787a596f7c 100644
--- a/packages/hls/2.5.0.0.Dockerfile
+++ b/packages/hls/2.5.0.0.Dockerfile
@@ -24,7 +24,7 @@ RUN apk add --no-cache patchelf findutils \
   && strip "out/bindist/$ARTIFACT/haskell-language-server-$HLS_VERSION/lib/$GHC_VERSION"/*.so \
   && emake bindist-tar
 
-FROM alpine:3.18 as hls
+FROM alpine:3.19 as hls
 
 ARG HLS_VERSION
 
diff --git a/prior/9.4.8.Dockerfile b/prior/9.4.8.Dockerfile
index 3ae095cc34f17aa23c850efe2fad307d7d21d226..165fe6dcd3503325e770111190b79e0630951a73 100644
--- a/prior/9.4.8.Dockerfile
+++ b/prior/9.4.8.Dockerfile
@@ -7,12 +7,6 @@ ARG CABAL_VERSION_BUILD=${CABAL_VERSION}
 
 FROM glcr.b-data.ch/ghc/ghc-musl:9.2.8 as bootstrap
 
-ARG GHC_VERSION_BUILD
-ARG CABAL_VERSION_BUILD
-
-ENV GHC_VERSION=${GHC_VERSION_BUILD} \
-    CABAL_VERSION=${CABAL_VERSION_BUILD}
-
 RUN apk upgrade --no-cache \
   && apk add --no-cache \
     autoconf \
@@ -32,6 +26,12 @@ RUN apk upgrade --no-cache \
     xz \
     zlib-dev
 
+FROM bootstrap as bootstrap-ghc
+
+ARG GHC_VERSION_BUILD
+
+ENV GHC_VERSION=${GHC_VERSION_BUILD}
+
 RUN cd /tmp \
   && curl -sSLO https://downloads.haskell.org/~ghc/"$GHC_VERSION"/ghc-"$GHC_VERSION"-src.tar.xz \
   && curl -sSLO https://downloads.haskell.org/~ghc/"$GHC_VERSION"/ghc-"$GHC_VERSION"-src.tar.xz.sig \
@@ -44,21 +44,30 @@ RUN cd /tmp \
   && cd "ghc-$GHC_VERSION" \
   && ./boot.source \
   && ./configure --disable-ld-override LD=ld.gold \
-  # Use the LLVM backend
-  # Switch llvm-targets from unknown-linux-gnueabihf->alpine-linux
-  # so we can match the llvm vendor string alpine uses
+  ## Use the LLVM backend
+  ## Switch llvm-targets from unknown-linux-gnueabihf->alpine-linux
+  ## so we can match the llvm vendor string alpine uses
   && sed -i -e 's/unknown-linux-gnueabihf/alpine-linux/g' llvm-targets \
   && sed -i -e 's/unknown-linux-gnueabi/alpine-linux/g' llvm-targets \
   && sed -i -e 's/unknown-linux-gnu/alpine-linux/g' llvm-targets \
   && cabal update \
-  # See https://unix.stackexchange.com/questions/519092/what-is-the-logic-of-using-nproc-1-in-make-command
+  ## See https://unix.stackexchange.com/questions/519092/what-is-the-logic-of-using-nproc-1-in-make-command
   && hadrian/build binary-dist -j"$(($(nproc)+1))" \
     --flavour=perf+llvm+split_sections \
-    --docs=none \
-  # See https://gitlab.haskell.org/ghc/ghc/-/wikis/commentary/libraries/version-history
-  && cabal install --allow-newer --constraint 'Cabal-syntax<3.9' "cabal-install-$CABAL_VERSION"
+    --docs=none
 
-FROM alpine:3.18 as builder
+FROM bootstrap as bootstrap-cabal
+
+ARG CABAL_VERSION_BUILD
+
+ENV CABAL_VERSION=${CABAL_VERSION_BUILD}
+
+## Build Cabal (the tool) with the GHC bootstrap version
+RUN cabal update \
+  ## See https://gitlab.haskell.org/ghc/ghc/-/wikis/commentary/libraries/version-history
+  && cabal install "cabal-install-$CABAL_VERSION"
+
+FROM alpine:3.19 as ghc-stage1
 
 LABEL org.opencontainers.image.licenses="MIT" \
       org.opencontainers.image.source="https://gitlab.b-data.ch/ghc/ghc-musl" \
@@ -107,16 +116,9 @@ RUN apk add --no-cache \
     zlib-dev \
     zlib-static
 
-COPY --from=bootstrap /tmp/ghc-"$GHC_VERSION"/_build/bindist/ghc-"$GHC_VERSION"-*-alpine-linux.tar.xz /tmp/
+COPY --from=bootstrap-ghc /tmp/ghc-"$GHC_VERSION"/_build/bindist/ghc-"$GHC_VERSION"-*-alpine-linux.tar.xz /tmp/
 
 RUN cd /tmp \
-  # Fix https://github.com/haskell/cabal/issues/8923
-  && PKG_CONFIG_VERSION="$(pkg-config --version)" \
-  && if [ "${PKG_CONFIG_VERSION%.*}" = "1.9" ]; then \
-    # Downgrade pkgconf from 1.9.x to 1.8.1
-    curl -sSLO http://dl-cdn.alpinelinux.org/alpine/v3.16/main/"$(uname -m)"/pkgconf-1.8.1-r0.apk; \
-    apk add --no-cache pkgconf-1.8.1-r0.apk; \
-  fi \
   ## Install GHC
   && tar -xJf ghc-"$GHC_VERSION"-*-alpine-linux.tar.xz \
   && cd ghc-"$GHC_VERSION"-*-alpine-linux \
@@ -132,25 +134,37 @@ RUN cd /tmp \
   ## Clean up
   && rm -rf /tmp/*
 
-## Install Cabal
-COPY --from=bootstrap /root/.cabal/bin/cabal /usr/local/bin/cabal
+FROM ghc-stage1 as ghc-stage2
 
-FROM builder as test
+## Install Cabal (the tool) built with the GHC bootstrap version
+COPY --from=bootstrap-cabal /root/.cabal/bin/cabal /usr/local/bin/cabal
+
+## Rebuild Cabal (the tool) with the GHC target version
+RUN cabal update \
+  && cabal install "cabal-install-$CABAL_VERSION"
+
+FROM ghc-stage1 as test
 
 WORKDIR /usr/local/src
 
+## Install Cabal (the tool) built with the GHC target version
+COPY --from=ghc-stage2 /root/.cabal/bin/cabal /usr/local/bin/cabal
+
 COPY Main.hs Main.hs
 
 RUN ghc -static -optl-pthread -optl-static Main.hs \
   && file Main \
   && ./Main \
-  # Test cabal workflow
+  ## Test cabal workflow
   && mkdir cabal-test \
   && cd cabal-test \
   && cabal update \
   && cabal init -n --is-executable -p tester -l MIT \
   && cabal run
 
-FROM builder as final
+FROM ghc-stage1
+
+## Install Cabal (the tool) built with the GHC target version
+COPY --from=ghc-stage2 /root/.cabal/bin/cabal /usr/local/bin/cabal
 
 CMD ["ghci"]
diff --git a/prior/9.6.3.Dockerfile b/prior/9.6.3.Dockerfile
index 96718cfe39a0f67f4fdcbe1e27af5a518bc22274..57a940f8b5f699a1621a941b55a62f7de8a6aba5 100644
--- a/prior/9.6.3.Dockerfile
+++ b/prior/9.6.3.Dockerfile
@@ -5,13 +5,7 @@ ARG STACK_VERSION=2.13.1
 ARG GHC_VERSION_BUILD=${GHC_VERSION}
 ARG CABAL_VERSION_BUILD=${CABAL_VERSION}
 
-FROM glcr.b-data.ch/ghc/ghc-musl:9.4.7 as bootstrap
-
-ARG GHC_VERSION_BUILD
-ARG CABAL_VERSION_BUILD
-
-ENV GHC_VERSION=${GHC_VERSION_BUILD} \
-    CABAL_VERSION=${CABAL_VERSION_BUILD}
+FROM glcr.b-data.ch/ghc/ghc-musl:9.4.8 as bootstrap
 
 RUN apk upgrade --no-cache \
   && apk add --no-cache \
@@ -32,6 +26,12 @@ RUN apk upgrade --no-cache \
     xz \
     zlib-dev
 
+FROM bootstrap as bootstrap-ghc
+
+ARG GHC_VERSION_BUILD
+
+ENV GHC_VERSION=${GHC_VERSION_BUILD}
+
 RUN cd /tmp \
   && curl -sSLO https://downloads.haskell.org/~ghc/"$GHC_VERSION"/ghc-"$GHC_VERSION"-src.tar.xz \
   && curl -sSLO https://downloads.haskell.org/~ghc/"$GHC_VERSION"/ghc-"$GHC_VERSION"-src.tar.xz.sig \
@@ -44,21 +44,30 @@ RUN cd /tmp \
   && cd "ghc-$GHC_VERSION" \
   && ./boot.source \
   && ./configure --disable-ld-override LD=ld.gold \
-  # Use the LLVM backend
-  # Switch llvm-targets from unknown-linux-gnueabihf->alpine-linux
-  # so we can match the llvm vendor string alpine uses
+  ## Use the LLVM backend
+  ## Switch llvm-targets from unknown-linux-gnueabihf->alpine-linux
+  ## so we can match the llvm vendor string alpine uses
   && sed -i -e 's/unknown-linux-gnueabihf/alpine-linux/g' llvm-targets \
   && sed -i -e 's/unknown-linux-gnueabi/alpine-linux/g' llvm-targets \
   && sed -i -e 's/unknown-linux-gnu/alpine-linux/g' llvm-targets \
   && cabal update \
-  # See https://unix.stackexchange.com/questions/519092/what-is-the-logic-of-using-nproc-1-in-make-command
+  ## See https://unix.stackexchange.com/questions/519092/what-is-the-logic-of-using-nproc-1-in-make-command
   && hadrian/build binary-dist -j"$(($(nproc)+1))" \
     --flavour=perf+llvm+split_sections \
-    --docs=none \
-  # See https://gitlab.haskell.org/ghc/ghc/-/wikis/commentary/libraries/version-history
-  && cabal install --allow-newer --constraint 'Cabal-syntax<3.11' "cabal-install-$CABAL_VERSION"
+    --docs=none
 
-FROM alpine:3.18 as builder
+FROM bootstrap as bootstrap-cabal
+
+ARG CABAL_VERSION_BUILD
+
+ENV CABAL_VERSION=${CABAL_VERSION_BUILD}
+
+## Build Cabal (the tool) with the GHC bootstrap version
+RUN cabal update \
+  ## See https://gitlab.haskell.org/ghc/ghc/-/wikis/commentary/libraries/version-history
+  && cabal install "cabal-install-$CABAL_VERSION"
+
+FROM alpine:3.19 as ghc-stage1
 
 LABEL org.opencontainers.image.licenses="MIT" \
       org.opencontainers.image.source="https://gitlab.b-data.ch/ghc/ghc-musl" \
@@ -107,16 +116,9 @@ RUN apk add --no-cache \
     zlib-dev \
     zlib-static
 
-COPY --from=bootstrap /tmp/ghc-"$GHC_VERSION"/_build/bindist/ghc-"$GHC_VERSION"-*-alpine-linux.tar.xz /tmp/
+COPY --from=bootstrap-ghc /tmp/ghc-"$GHC_VERSION"/_build/bindist/ghc-"$GHC_VERSION"-*-alpine-linux.tar.xz /tmp/
 
 RUN cd /tmp \
-  # Fix https://github.com/haskell/cabal/issues/8923
-  && PKG_CONFIG_VERSION="$(pkg-config --version)" \
-  && if [ "${PKG_CONFIG_VERSION%.*}" = "1.9" ]; then \
-    # Downgrade pkgconf from 1.9.x to 1.8.1
-    curl -sSLO http://dl-cdn.alpinelinux.org/alpine/v3.16/main/"$(uname -m)"/pkgconf-1.8.1-r0.apk; \
-    apk add --no-cache pkgconf-1.8.1-r0.apk; \
-  fi \
   ## Install GHC
   && tar -xJf ghc-"$GHC_VERSION"-*-alpine-linux.tar.xz \
   && cd ghc-"$GHC_VERSION"-*-alpine-linux \
@@ -132,25 +134,37 @@ RUN cd /tmp \
   ## Clean up
   && rm -rf /tmp/*
 
-## Install Cabal
-COPY --from=bootstrap /root/.cabal/bin/cabal /usr/local/bin/cabal
+FROM ghc-stage1 as ghc-stage2
 
-FROM builder as test
+## Install Cabal (the tool) built with the GHC bootstrap version
+COPY --from=bootstrap-cabal /root/.cabal/bin/cabal /usr/local/bin/cabal
+
+## Rebuild Cabal (the tool) with the GHC target version
+RUN cabal update \
+  && cabal install "cabal-install-$CABAL_VERSION"
+
+FROM ghc-stage1 as test
 
 WORKDIR /usr/local/src
 
+## Install Cabal (the tool) built with the GHC target version
+COPY --from=ghc-stage2 /root/.local/bin/cabal /usr/local/bin/cabal
+
 COPY Main.hs Main.hs
 
 RUN ghc -static -optl-pthread -optl-static Main.hs \
   && file Main \
   && ./Main \
-  # Test cabal workflow
+  ## Test cabal workflow
   && mkdir cabal-test \
   && cd cabal-test \
   && cabal update \
   && cabal init -n --is-executable -p tester -l MIT \
   && cabal run
 
-FROM builder as final
+FROM ghc-stage1
+
+## Install Cabal (the tool) built with the GHC target version
+COPY --from=ghc-stage2 /root/.local/bin/cabal /usr/local/bin/cabal
 
 CMD ["ghci"]
diff --git a/prior/9.6.4.Dockerfile b/prior/9.6.4.Dockerfile
new file mode 100644
index 0000000000000000000000000000000000000000..48bf384de6bf8038f3840ec40118f3d77b59addd
--- /dev/null
+++ b/prior/9.6.4.Dockerfile
@@ -0,0 +1,170 @@
+ARG GHC_VERSION=9.6.4
+ARG CABAL_VERSION=3.10.1.0
+ARG STACK_VERSION=2.13.1
+
+ARG GHC_VERSION_BUILD=${GHC_VERSION}
+ARG CABAL_VERSION_BUILD=${CABAL_VERSION}
+
+FROM glcr.b-data.ch/ghc/ghc-musl:9.4.8 as bootstrap
+
+RUN apk upgrade --no-cache \
+  && apk add --no-cache \
+    autoconf \
+    automake \
+    binutils-gold \
+    build-base \
+    coreutils \
+    cpio \
+    curl \
+    gnupg \
+    linux-headers \
+    libffi-dev \
+    llvm14 \
+    ncurses-dev \
+    perl \
+    python3 \
+    xz \
+    zlib-dev
+
+FROM bootstrap as bootstrap-ghc
+
+ARG GHC_VERSION_BUILD
+
+ENV GHC_VERSION=${GHC_VERSION_BUILD}
+
+RUN cd /tmp \
+  && curl -sSLO https://downloads.haskell.org/~ghc/"$GHC_VERSION"/ghc-"$GHC_VERSION"-src.tar.xz \
+  && curl -sSLO https://downloads.haskell.org/~ghc/"$GHC_VERSION"/ghc-"$GHC_VERSION"-src.tar.xz.sig \
+  && gpg --keyserver hkps://keyserver.ubuntu.com:443 \
+    --receive-keys 88B57FCF7DB53B4DB3BFA4B1588764FBE22D19C4 || \
+    gpg --keyserver hkp://keyserver.ubuntu.com:80 \
+    --receive-keys 88B57FCF7DB53B4DB3BFA4B1588764FBE22D19C4 \
+  && gpg --verify "ghc-$GHC_VERSION-src.tar.xz.sig" "ghc-$GHC_VERSION-src.tar.xz" \
+  && tar -xJf "ghc-$GHC_VERSION-src.tar.xz" \
+  && cd "ghc-$GHC_VERSION" \
+  && ./boot.source \
+  && ./configure --disable-ld-override LD=ld.gold \
+  ## Use the LLVM backend
+  ## Switch llvm-targets from unknown-linux-gnueabihf->alpine-linux
+  ## so we can match the llvm vendor string alpine uses
+  && sed -i -e 's/unknown-linux-gnueabihf/alpine-linux/g' llvm-targets \
+  && sed -i -e 's/unknown-linux-gnueabi/alpine-linux/g' llvm-targets \
+  && sed -i -e 's/unknown-linux-gnu/alpine-linux/g' llvm-targets \
+  && cabal update \
+  ## See https://unix.stackexchange.com/questions/519092/what-is-the-logic-of-using-nproc-1-in-make-command
+  && hadrian/build binary-dist -j"$(($(nproc)+1))" \
+    --flavour=perf+llvm+split_sections \
+    --docs=none
+
+FROM bootstrap as bootstrap-cabal
+
+ARG CABAL_VERSION_BUILD
+
+ENV CABAL_VERSION=${CABAL_VERSION_BUILD}
+
+## Build Cabal (the tool) with the GHC bootstrap version
+RUN cabal update \
+  ## See https://gitlab.haskell.org/ghc/ghc/-/wikis/commentary/libraries/version-history
+  && cabal install "cabal-install-$CABAL_VERSION"
+
+FROM alpine:3.19 as ghc-stage1
+
+LABEL org.opencontainers.image.licenses="MIT" \
+      org.opencontainers.image.source="https://gitlab.b-data.ch/ghc/ghc-musl" \
+      org.opencontainers.image.vendor="Olivier Benz" \
+      org.opencontainers.image.authors="Olivier Benz <olivier.benz@b-data.ch>"
+
+ARG GHC_VERSION_BUILD
+ARG CABAL_VERSION_BUILD
+ARG STACK_VERSION
+
+ENV GHC_VERSION=${GHC_VERSION_BUILD} \
+    CABAL_VERSION=${CABAL_VERSION_BUILD} \
+    STACK_VERSION=${STACK_VERSION}
+
+RUN apk add --no-cache \
+    bash \
+    build-base \
+    bzip2 \
+    bzip2-dev \
+    bzip2-static \
+    curl \
+    curl-static \
+    dpkg \
+    fakeroot \
+    git \
+    gmp-dev \
+    libcurl \
+    libffi \
+    libffi-dev \
+    llvm14 \
+    ncurses-dev \
+    ncurses-static \
+    openssl-dev \
+    openssl-libs-static \
+    pcre \
+    pcre-dev \
+    pcre2 \
+    pcre2-dev \
+    perl \
+    ## Install shadow for `stack --docker`
+    shadow \
+    wget \
+    xz \
+    xz-dev \
+    zlib \
+    zlib-dev \
+    zlib-static
+
+COPY --from=bootstrap-ghc /tmp/ghc-"$GHC_VERSION"/_build/bindist/ghc-"$GHC_VERSION"-*-alpine-linux.tar.xz /tmp/
+
+RUN cd /tmp \
+  ## Install GHC
+  && tar -xJf ghc-"$GHC_VERSION"-*-alpine-linux.tar.xz \
+  && cd ghc-"$GHC_VERSION"-*-alpine-linux \
+  && ./configure --disable-ld-override \
+  && make install \
+  ## Install Stack
+  && cd /tmp \
+  && curl -sSLO https://github.com/commercialhaskell/stack/releases/download/v"$STACK_VERSION"/stack-"$STACK_VERSION"-linux-"$(uname -m)".tar.gz \
+  && curl -sSLO https://github.com/commercialhaskell/stack/releases/download/v"$STACK_VERSION"/stack-"$STACK_VERSION"-linux-"$(uname -m)".tar.gz.sha256 \
+  && sha256sum -cs stack-"$STACK_VERSION"-linux-"$(uname -m)".tar.gz.sha256 \
+  && tar -xzf stack-"$STACK_VERSION"-linux-"$(uname -m)".tar.gz \
+  && mv stack-"$STACK_VERSION"-linux-"$(uname -m)"/stack /usr/local/bin/stack \
+  ## Clean up
+  && rm -rf /tmp/*
+
+FROM ghc-stage1 as ghc-stage2
+
+## Install Cabal (the tool) built with the GHC bootstrap version
+COPY --from=bootstrap-cabal /root/.cabal/bin/cabal /usr/local/bin/cabal
+
+## Rebuild Cabal (the tool) with the GHC target version
+RUN cabal update \
+  && cabal install "cabal-install-$CABAL_VERSION"
+
+FROM ghc-stage1 as test
+
+WORKDIR /usr/local/src
+
+## Install Cabal (the tool) built with the GHC target version
+COPY --from=ghc-stage2 /root/.local/bin/cabal /usr/local/bin/cabal
+
+COPY Main.hs Main.hs
+
+RUN ghc -static -optl-pthread -optl-static Main.hs \
+  && file Main \
+  && ./Main \
+  ## Test cabal workflow
+  && mkdir cabal-test \
+  && cd cabal-test \
+  && cabal update \
+  && cabal init -n --is-executable -p tester -l MIT \
+  && cabal run
+
+FROM ghc-stage1
+
+## Install Cabal (the tool) built with the GHC target version
+COPY --from=ghc-stage2 /root/.local/bin/cabal /usr/local/bin/cabal
+
+CMD ["ghci"]