@@ -1,25 +1,39 @@
1−# Create: https://gist.github.com/rlefevre/1523f47e75310e28eee243c9c5651ac9
1+# Based initially on https://gist.github.com/rlefevre/1523f47e75310e28eee243c9c5651ac9
3+# Build Linux x64 binary from elm compiler top-level directory:
4+# $ docker build -t elm -f installers/linux/Dockerfile .
6+# Retrieve elm Linux binary:
7+# $ docker cp $(docker create elm):/usr/local/bin/elm DESTINATION_DIRECTORY
9+# Delete docker elm image:
15+# Delete all unused docker images:
2−# Delete: docker system prune -a ; docker images -a
16+# $ docker system prune -a
18+# Use Alpine 3.11 with GHC 8.6.5
4−FROM alpine:3.10
19+FROM alpine:3.11
6−# branch
21+# Install packages required to build elm
7−ARG branch=master
22+RUN apk add --no-cache ghc cabal wget musl-dev zlib-dev zlib-static ncurses-dev ncurses-static
11−# Install required packages
24+WORKDIR /elm
12−RUN apk add --update ghc cabal git musl-dev zlib-dev ncurses-dev ncurses-static wget
14−# Checkout elm compiler
26+# Import source code
15−WORKDIR /tmp
27+COPY builder builder/
16−RUN git clone -b $branch https://github.com/elm/compiler.git
28+COPY compiler compiler
30+COPY terminal terminal/
31+COPY cabal.config elm.cabal LICENSE ./
18−# Build a statically linked elm binary
33+# Build statically linked elm binary
20−RUN git checkout $commit
21−RUN rm worker/elm.cabal
22RUN cabal new-update
34RUN cabal new-update
23−RUN cabal new-configure --disable-executable-dynamic --ghc-option=-optl=-static --ghc-option=-optl=-pthread
35+RUN cabal new-build --ghc-option=-optl=-static --ghc-option=-split-sections
25−RUN strip -s ./dist-newstyle/build/x86_64-linux/ghc-8.4.3/elm-0.19.1/x/elm/build/elm/elm
36+RUN cp ./dist-newstyle/build/x86_64-linux/ghc-*/elm-*/x/elm/build/elm/elm /usr/local/bin/elm
38+# Remove debug symbols to optimize the binary size
39+RUN strip -s /usr/local/bin/elm