Skip to content

Commit 19757a3

Browse files
committed
Add linux Docker build system
1 parent 7d7dc07 commit 19757a3

File tree

5 files changed

+118
-6
lines changed

5 files changed

+118
-6
lines changed

.github/workflows/build-linux-ef.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,12 @@ jobs:
5151
path: ${{ steps.setup-haskell.outputs.cabal-store }}
5252
key: cabal-release-v1-${{ runner.os }}-${{ hashFiles('cabal.project.freeze') }}
5353
- run: cabal v2-update
54-
- run: ./build.sh -- dist-dependencies
55-
- run: ./build.sh -- dist
54+
- uses: satackey/action-docker-layer-caching@v0.0.11
55+
# Ignore the failure of a step and avoid terminating the job.
56+
continue-on-error: true
57+
- run: ./build.sh --verbose --verbose -- publish-1.0.2
58+
# - run: ./build.sh -- dist-dependencies
59+
# - run: ./build.sh -- dist
5660
# - name: Sign artifacts
5761
# run: |
5862
# for i in dist/*; do

Dockerfile

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
FROM alpine:latest as build
2+
3+
ENV GHC_VERSION 9.0.2
4+
5+
ENV LANG C.UTF-8
6+
7+
# Install ghc and cabal-isntall
8+
RUN apk add --no-cache curl
9+
RUN curl https://downloads.haskell.org/~ghcup/0.1.17.3/x86_64-linux-ghcup-0.1.17.3 > /usr/local/bin/ghcup && \
10+
chmod +x /usr/local/bin/ghcup
11+
RUN ghcup install cabal recommended
12+
RUN apk add --no-cache \
13+
alpine-sdk \
14+
autoconf \
15+
gcc \
16+
gmp \
17+
gmp-dev \
18+
libffi \
19+
libffi-dev \
20+
llvm10 \
21+
make \
22+
musl-dev \
23+
ncurses-dev \
24+
ncurses-static \
25+
tree \
26+
wget \
27+
zlib-dev \
28+
zlib-static
29+
RUN ghcup install ghc $GHC_VERSION && \
30+
ghcup set ghc $GHC_VERSION
31+
ENV PATH $PATH:/root/.ghcup/bin
32+
33+
34+
# FIX https://bugs.launchpad.net/ubuntu/+source/gcc-4.4/+bug/640734
35+
# Use the next line to debug the right file source if this area starts failing in future
36+
# RUN tree /usr/lib/gcc/x86_64-alpine-linux-musl
37+
# @TODO is there a sure-fire way of getting this path?
38+
WORKDIR /usr/lib/gcc/x86_64-alpine-linux-musl/10.3.1/
39+
RUN cp crtbeginT.o crtbeginT.o.orig
40+
RUN cp crtbeginS.o crtbeginT.o
41+
RUN cp crtend.o crtend.o.orig
42+
RUN cp crtendS.o crtend.o
43+
44+
45+
WORKDIR /lamdera
46+
47+
# Install lamdera dependencies
48+
COPY cabal.project ./
49+
COPY cabal.project.freeze ./
50+
51+
COPY elm.cabal ./
52+
53+
RUN cabal v2-update
54+
55+
# RUN cabal v2-install --lib shake
56+
# RUN cabal v2-build --only-dependencies
57+
# RUN cabal v2-build --only-dependencies --enable-tests
58+
# RUN cabal v2-install ShellCheck
59+
RUN cabal v2-build --ghc-option=-optl=-static --ghc-option=-split-sections -O0 --only-dependencies
60+
61+
# Build lamdera
62+
COPY ./ .
63+
64+
ARG ELM_FORMAT_VERSION="unknown"
65+
RUN mkdir generated && echo -e "module Build_lamdera where\n\ngitDescribe :: String\ngitDescribe = \"$ELM_FORMAT_VERSION\"\n" > generated/Build_lamdera.hs
66+
RUN cabal v2-build --ghc-option=-optl=-static --ghc-option=-split-sections -O0
67+
RUN cp dist-newstyle/build/x86_64-linux/ghc-*/elm-*/x/lamdera/*opt/build/lamdera/lamdera ./
68+
RUN strip -s ./lamdera
69+
70+
71+
FROM scratch as artifact
72+
COPY --from=build /lamdera/lamdera /lamdera

Shakefile.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ main = do
4747
-- ]
4848
-- phony "profile" $ need [ "_build/tests/test-files/prof.ok" ]
4949
phony "dist" $ need [ "dist-lamdera" ]
50-
-- phonyPrefix "publish-" $ \version ->
51-
-- need [ "elm-format-publish-" ++ version ]
50+
phonyPrefix "publish-" $ \version ->
51+
need [ "lamdera-publish-" ++ version ]
5252

5353
phony "clean" $ do
5454
removeFilesAfter "dist-newstyle" [ "//*" ]

Shakefiles/Haskell.hs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,11 @@ executable target projectName gitDescribe =
112112
need $
113113
concatMap (\target ->
114114
[ "publish" </> version </> projectName ++ "-" ++ version ++ "-" ++ show target <.> Shakefiles.Platform.zipFormatFor target
115-
, "publish" </> version </> projectName ++ "-" ++ version ++ "-" ++ show target <.> Shakefiles.Platform.zipFormatFor target <.> "asc"
115+
-- , "publish" </> version </> projectName ++ "-" ++ version ++ "-" ++ show target <.> Shakefiles.Platform.zipFormatFor target <.> "asc"
116116
]
117117
)
118-
Shakefiles.Platform.all
118+
-- Shakefiles.Platform.all
119+
[ Shakefiles.Platform.Linux ]
119120

120121
let buildInDocker =
121122
[ Shakefiles.Platform.Linux

package/linux/build-in-docker.sh

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/bin/bash
2+
3+
set -euo pipefail
4+
5+
if [[ $(docker --version) == *" 19.0"[0-2]* ]]; then
6+
echo "ERROR: Docker >= 19.03 is required"
7+
docker --version
8+
exit 1
9+
fi
10+
11+
set -x
12+
13+
export DOCKER_BUILDKIT=1
14+
15+
SHA="${1-}"
16+
if [ -z "$SHA" ]; then
17+
CONTEXT="."
18+
# VERSION="$(git describe --abbrev=8)"
19+
DEST="_build/docker/local/linux-x64"
20+
else
21+
CONTEXT="-"
22+
# VERSION="$(git describe --abbrev=8 "$SHA")"
23+
DEST="_build/docker/$SHA/linux-x64"
24+
fi
25+
26+
VERSION="0.19.1-20-gd87b2f0d"
27+
28+
echo "Building with SHA: $SHA"
29+
echo "Building with Context: $CONTEXT"
30+
echo "Building with Dest: $DEST"
31+
32+
rm -Rf "$DEST"
33+
git archive --format=tar.gz "$SHA" | \
34+
docker build -t lamdera-next-linux --build-arg "ELM_FORMAT_VERSION=$VERSION" --target artifact --output type=local,dest="$DEST/" "$CONTEXT"
35+
"$DEST/lamdera" --help

0 commit comments

Comments
 (0)