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