From 037af1b95bc364efd7a040afea516e9f1026c124 Mon Sep 17 00:00:00 2001 From: John MacFarlane <jgm@berkeley.edu> Date: Fri, 17 Mar 2017 16:02:49 +0100 Subject: [PATCH] Improved static linux alpine build. * Use -split-objs (reduces executable size from ~50M to 32M), at cost of much slower compilation. * Moved building of prereqs from CMD to RUN, so they can be cached. Doing 'make build' will fetch the latest from git and rebuild pandoc, but dependencies needn't be rebuilt. --- static-linux/Dockerfile | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/static-linux/Dockerfile b/static-linux/Dockerfile index 3c62ebcf9..b0b169120 100644 --- a/static-linux/Dockerfile +++ b/static-linux/Dockerfile @@ -9,10 +9,13 @@ RUN apk update RUN apk add alpine-sdk git ca-certificates ghc cabal stack zlib-dev RUN stack update RUN stack config set system-ghc --global true -ADD ./ /usr/src/ +RUN mkdir -p /etc/stack +RUN echo "build: { split-objs: true }" > /etc/stack/config.yaml +RUN mkdir -p /usr/src/ WORKDIR /usr/src/ RUN git clone https://github.com/jgm/pandoc WORKDIR /usr/src/pandoc +RUN stack install --local-bin-path /usr/bin hsb2hs +RUN stack install --only-dependencies --flag 'pandoc:embed_data_files' --test --ghc-options '-O2 -optc-Os -optl-static -fPIC' CMD git pull -CMD stack install --local-bin-path /usr/bin hsb2hs -CMD stack install --local-bin-path /artifacts --flag 'pandoc:embed_data_files' --test --ghc-options '-optl-static -fPIC' +CMD stack install --local-bin-path /artifacts --flag 'pandoc:embed_data_files' --test --ghc-options '-O2 -optc-Os -optl-static -fPIC'