Last active
January 15, 2020 21:00
-
-
Save pjhanzlik/8292f1f9697cb8c2c03b509723957893 to your computer and use it in GitHub Desktop.
Static binary Elm docker image (based on elm/compiler PR #2044 Dockerfile)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Based on https://gist.github.com/rlefevre/1523f47e75310e28eee243c9c5651ac9 | |
# | |
# Build Linux x64 binary from elm compiler top-level directory: | |
# $ docker build -t elm -f installers/linux/Dockerfile . | |
# | |
# Retrieve elm Linux binary: | |
# $ docker cp $(docker create elm):/elm DESTINATION_DIRECTORY | |
# | |
# Delete docker elm image: | |
# $ docker rmi elm | |
# | |
# Display all images: | |
# $ docker images -a | |
# | |
# Delete all unused docker images: | |
# $ docker system prune -a | |
FROM alpine:3.11 AS builder | |
# Install required packages | |
RUN apk add --no-cache ghc cabal wget musl-dev zlib-dev zlib-static ncurses-dev ncurses-static | |
# Import source code | |
WORKDIR /elm | |
COPY . . | |
RUN rm worker/elm.cabal | |
# Build elm binary | |
RUN cabal new-update | |
RUN cabal new-build --ghc-option=-optl=-static --ghc-option=-split-sections | |
RUN strip -s ./dist-newstyle/build/x86_64-linux/ghc-*/elm-*/x/elm/build/elm/elm | |
FROM scratch | |
COPY --from=builder /elm/dist-newstyle/build/x86_64-linux/ghc-*/elm-*/x/elm/build/elm/elm / |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment