Skip to content

Commit 2db6983

Browse files
committed
Static Linux builds with Alpine
1 parent ab0e190 commit 2db6983

File tree

3 files changed

+50
-6
lines changed

3 files changed

+50
-6
lines changed

.azure/azure-linux-template.yml

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,26 +10,35 @@ 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"
1926
style:
2027
BUILD: style
28+
EXTRA_SUFFIX: ""
2129
pedantic:
2230
BUILD: pedantic
2331
STACK_YAML: stack.yaml
32+
EXTRA_SUFFIX: ""
2433
steps:
2534
- script: |
2635
export STACK_ROOT="$(Build.SourcesDirectory)"/.stack-root;
2736
mkdir -p ~/.local/bin
2837
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
2938
tar xzf ~/.local/bin/cache-s3.tar.gz -C ~/.local/bin
3039
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}"
40+
cache-s3 --prefix="${CACHE_S3_PREFIX}" --git-branch="$(Build.SourceBranchName)" --suffix="${OS_NAME}${EXTRA_SUFFIX}" restore stack --base-branch="${BASE_BRANCH}"
41+
cache-s3 --prefix="${CACHE_S3_PREFIX}" --git-branch="$(Build.SourceBranchName)" --suffix="${OS_NAME}${EXTRA_SUFFIX}" restore stack work --base-branch="${BASE_BRANCH}"
3342
etc/scripts/ci-setup.sh
3443
case "$BUILD" in
3544
style)
@@ -38,7 +47,7 @@ jobs:
3847
;;
3948
*)
4049
export PATH=$HOME/.local/bin:$PATH
41-
stack --install-ghc $ARGS test --bench --only-dependencies
50+
stack $ARGS test --bench --only-dependencies
4251
;;
4352
esac
4453
GHC_OPTIONS="-Werror"
@@ -51,7 +60,11 @@ jobs:
5160
hlint test/ --cpp-simple
5261
;;
5362
stack)
54-
stack test --haddock --no-haddock-deps --ghc-options="$GHC_OPTIONS"
63+
stack test --haddock --no-haddock-deps --ghc-options="$GHC_OPTIONS" --copy-bins --local-bin-path bin
64+
65+
# Make sure Alpine actually builds a static exe that works on Ubuntu
66+
./bin/stack --version
67+
ldd ./bin/stack || true # ldd returns exit code 1 on statics, which we don't want to fail for
5568
;;
5669
pedantic)
5770
stack --system-ghc build --pedantic
@@ -94,9 +107,9 @@ jobs:
94107
export AWS_SECRET_ACCESS_KEY="$(AWS_SECRET_ACCESS_KEY)";
95108
export STACK_ROOT="$(Build.SourcesDirectory)"/.stack-root;
96109
if [ "$(Build.SourceBranchName)" = "${BASE_BRANCH}" ]; then
97-
cache-s3 --prefix="${CACHE_S3_PREFIX}" --git-branch="$(Build.SourceBranchName)" --suffix="${OS_NAME}" save stack;
110+
cache-s3 --prefix="${CACHE_S3_PREFIX}" --git-branch="$(Build.SourceBranchName)" --suffix="${OS_NAME}${EXTRA_SUFFIX}" save stack;
98111
fi;
99-
cache-s3 --prefix="${CACHE_S3_PREFIX}" --git-branch="$(Build.SourceBranchName)" --suffix="${OS_NAME}" save stack work
112+
cache-s3 --prefix="${CACHE_S3_PREFIX}" --git-branch="$(Build.SourceBranchName)" --suffix="${OS_NAME}${EXTRA_SUFFIX}" save stack work
100113
condition: and(succeeded(), in(variables['Build.Reason'], 'IndividualCI', 'BatchedCI'))
101114
env:
102115
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+
#repo: fpco/alpine-haskell-stack:8.6.5
9+
repo: fpco/alpine-haskell-stack@sha256:665495cf78a9a7a667a45061a1322989b128d3443d87821fac1445dc85984804
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)