Skip to content

Commit 88bd6cd

Browse files
committed
Static Linux builds with Alpine
1 parent ab0e190 commit 88bd6cd

File tree

3 files changed

+51
-6
lines changed

3 files changed

+51
-6
lines changed

.azure/azure-linux-template.yml

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,26 +10,36 @@ jobs:
1010
GHC 8.4:
1111
BUILD: stack
1212
STACK_YAML: stack-ghc-84.yaml
13+
EXTRA_SUFFIX: ""
1314
GHC 8.6:
1415
BUILD: stack
1516
STACK_YAML: stack-ghc-86.yaml
17+
EXTRA_SUFFIX: ""
1618
GHC 8.8:
1719
BUILD: stack
1820
STACK_YAML: stack-ghc-88.yaml
21+
EXTRA_SUFFIX: ""
22+
Alpine:
23+
BUILD: stack
24+
STACK_YAML: stack-alpine.yaml
25+
EXTRA_SUFFIX: "alpine"
26+
ARGS: --system-ghc --no-install-ghc
1927
style:
2028
BUILD: style
29+
EXTRA_SUFFIX: ""
2130
pedantic:
2231
BUILD: pedantic
2332
STACK_YAML: stack.yaml
33+
EXTRA_SUFFIX: ""
2434
steps:
2535
- script: |
2636
export STACK_ROOT="$(Build.SourcesDirectory)"/.stack-root;
2737
mkdir -p ~/.local/bin
2838
curl -f -L "https://github.com/fpco/cache-s3/releases/download/${CACHE_S3_VERSION}/cache-s3-${CACHE_S3_VERSION}-${OS_NAME}-x86_64.tar.gz" -o ~/.local/bin/cache-s3.tar.gz
2939
tar xzf ~/.local/bin/cache-s3.tar.gz -C ~/.local/bin
3040
export PATH=$HOME/.local/bin:$PATH;
31-
cache-s3 --prefix="${CACHE_S3_PREFIX}" --git-branch="$(Build.SourceBranchName)" --suffix="${OS_NAME}" restore stack --base-branch="${BASE_BRANCH}"
32-
cache-s3 --prefix="${CACHE_S3_PREFIX}" --git-branch="$(Build.SourceBranchName)" --suffix="${OS_NAME}" restore stack work --base-branch="${BASE_BRANCH}"
41+
cache-s3 --prefix="${CACHE_S3_PREFIX}" --git-branch="$(Build.SourceBranchName)" --suffix="${OS_NAME}${EXTRA_SUFFIX}" restore stack --base-branch="${BASE_BRANCH}"
42+
cache-s3 --prefix="${CACHE_S3_PREFIX}" --git-branch="$(Build.SourceBranchName)" --suffix="${OS_NAME}${EXTRA_SUFFIX}" restore stack work --base-branch="${BASE_BRANCH}"
3343
etc/scripts/ci-setup.sh
3444
case "$BUILD" in
3545
style)
@@ -38,7 +48,7 @@ jobs:
3848
;;
3949
*)
4050
export PATH=$HOME/.local/bin:$PATH
41-
stack --install-ghc $ARGS test --bench --only-dependencies
51+
stack $ARGS test --bench --only-dependencies
4252
;;
4353
esac
4454
GHC_OPTIONS="-Werror"
@@ -51,7 +61,11 @@ jobs:
5161
hlint test/ --cpp-simple
5262
;;
5363
stack)
54-
stack test --haddock --no-haddock-deps --ghc-options="$GHC_OPTIONS"
64+
stack $ARGS test --haddock --no-haddock-deps --ghc-options="$GHC_OPTIONS" --copy-bins --local-bin-path bin
65+
66+
# Make sure Alpine actually builds a static exe that works on Ubuntu
67+
./bin/stack --version
68+
ldd ./bin/stack || true # ldd returns exit code 1 on statics, which we don't want to fail for
5569
;;
5670
pedantic)
5771
stack --system-ghc build --pedantic
@@ -94,9 +108,9 @@ jobs:
94108
export AWS_SECRET_ACCESS_KEY="$(AWS_SECRET_ACCESS_KEY)";
95109
export STACK_ROOT="$(Build.SourcesDirectory)"/.stack-root;
96110
if [ "$(Build.SourceBranchName)" = "${BASE_BRANCH}" ]; then
97-
cache-s3 --prefix="${CACHE_S3_PREFIX}" --git-branch="$(Build.SourceBranchName)" --suffix="${OS_NAME}" save stack;
111+
cache-s3 --prefix="${CACHE_S3_PREFIX}" --git-branch="$(Build.SourceBranchName)" --suffix="${OS_NAME}${EXTRA_SUFFIX}" save stack;
98112
fi;
99-
cache-s3 --prefix="${CACHE_S3_PREFIX}" --git-branch="$(Build.SourceBranchName)" --suffix="${OS_NAME}" save stack work
113+
cache-s3 --prefix="${CACHE_S3_PREFIX}" --git-branch="$(Build.SourceBranchName)" --suffix="${OS_NAME}${EXTRA_SUFFIX}" save stack work
100114
condition: and(succeeded(), in(variables['Build.Reason'], 'IndividualCI', 'BatchedCI'))
101115
env:
102116
OS_NAME: ${{ parameters.os }}

.azure/azure-nightly-template-linux.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ jobs:
2525
OS_NAME: ${{ parameters.os }}
2626
AWS_ACCESS_KEY_ID: $(AWS_ACCESS_KEY_ID)
2727
AWS_SECRET_ACCESS_KEY: $(AWS_SECRET_ACCESS_KEY)
28+
STACK_YAML: $(Build.SourcesDirectory)/stack-alpine.yaml
2829
displayName: 'Installation ${{parameters.os}}'
2930
- script: |
3031
set -ex

stack-alpine.yaml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
resolver: lts-14.27
2+
3+
packages:
4+
- .
5+
6+
docker:
7+
enable: true
8+
#image: fpco/alpine-haskell-stack:8.6.5
9+
image: fpco/alpine-haskell-stack@sha256:49e7e15f3b1d3f882ba5bb701463b1d508fbf40e5aafce6ea31acd210da570ba
10+
11+
flags:
12+
stack:
13+
hide-dependency-versions: true
14+
supported-build: true
15+
16+
ghc-options:
17+
"$locals": -fhide-source-paths -optl-static
18+
19+
extra-deps:
20+
- Cabal-3.0.0.0@rev:0
21+
- hpack-0.33.0@rev:0
22+
- http-download-0.2.0.0@rev:0
23+
- filelock-0.1.1.4@rev:0
24+
- pantry-0.4.0.1@rev:0
25+
- casa-client-0.0.1@rev:0
26+
- casa-types-0.0.1@rev:0
27+
28+
drop-packages:
29+
# See https://github.com/commercialhaskell/stack/pull/4712
30+
- cabal-install

0 commit comments

Comments
 (0)