From 473b4ad62d676188d1127e9b4fc4b8fdec514207 Mon Sep 17 00:00:00 2001
From: John MacFarlane <jgm@berkeley.edu>
Date: Mon, 26 Nov 2018 23:15:06 -0800
Subject: [PATCH] Update linux Dockerfile to use cabal new-build.

---
 linux/Dockerfile | 33 ++++++++++++++-------------------
 1 file changed, 14 insertions(+), 19 deletions(-)

diff --git a/linux/Dockerfile b/linux/Dockerfile
index e533f6c36..6abe5ec2e 100644
--- a/linux/Dockerfile
+++ b/linux/Dockerfile
@@ -1,29 +1,24 @@
 # USE ALPINE LINUX
 FROM alpine
 RUN apk update
-RUN apk add alpine-sdk git ca-certificates ghc gmp-dev zlib-dev bash dpkg fakeroot
-# GRAB A RECENT BINARY OF STACK
-RUN curl -L https://github.com/commercialhaskell/stack/releases/download/v1.9.1/stack-1.9.1-linux-x86_64-static.tar.gz | tar xvz
-RUN cp stack-1.9.1-linux-x86_64-static/stack /usr/local/bin/stack
-RUN chmod +x /usr/local/bin/stack
-ENV PATH="/usr/local/bin:${PATH}"
-RUN ulimit -n 4096
-RUN stack config set system-ghc --global true
-RUN stack setup --resolver lts-12.12
+RUN apk add alpine-sdk git ca-certificates ghc gmp-dev zlib-dev bash dpkg fakeroot cabal
 RUN mkdir -p /usr/src/
 WORKDIR /usr/src/
 RUN git clone https://github.com/jgm/pandoc
+RUN git clone https://github.com/jgm/pandoc-citeproc
 WORKDIR /usr/src/pandoc
-CMD git pull && \
+RUN cabal update && \
+    cabal install cabal-install-2.4.0.0 && \
+    cp $HOME/.cabal/bin/cabal /usr/bin/
+CMD cabal --version && \
+    ghc --version && \
+    git pull && \
     git checkout -b work $TREE && \
-    stack install \
-      --flag 'pandoc:static' \
-      --flag 'pandoc:embed_data_files' \
-      --flag 'pandoc-citeproc:static' \
-      --flag 'pandoc-citeproc:embed_data_files' \
-      --flag 'hslua:-export-dynamic' \
-      --ghc-options '-O2 -optc-Os -optl=-pthread -optl=-static -fPIC' \
-      --local-bin-path /artifacts \
-      pandoc pandoc-citeproc && \
+    cabal new-update && \
+    cabal new-clean && \
+    cabal new-configure --enable-tests -f-export-dynamic -fstatic -fembed_data_files -fbibutils --ghc-options '-O2 -optc-Os -optl=-pthread -optl=-static -fPIC' . pandoc-citeproc && \
+    cabal new-build . pandoc-citeproc && \
+    cabal new-test -j1 . pandoc-citeproc && \
+    for f in $(find dist-newstyle -name 'pandoc*' -type f -perm +400); do cp $f /artifacts/; done && \
     bash linux/make_deb.sh && \
     bash linux/make_tarball.sh