Skip to content

Commit

Permalink
Static Linux builds with Alpine
Browse files Browse the repository at this point in the history
  • Loading branch information
snoyberg committed Apr 21, 2020
1 parent ab0e190 commit 2db6983
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 6 deletions.
25 changes: 19 additions & 6 deletions .azure/azure-linux-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,35 @@ jobs:
GHC 8.4:
BUILD: stack
STACK_YAML: stack-ghc-84.yaml
EXTRA_SUFFIX: ""
GHC 8.6:
BUILD: stack
STACK_YAML: stack-ghc-86.yaml
EXTRA_SUFFIX: ""
GHC 8.8:
BUILD: stack
STACK_YAML: stack-ghc-88.yaml
EXTRA_SUFFIX: ""
Alpine:
BUILD: stack
STACK_YAML: stack-alpine.yaml
EXTRA_SUFFIX: "alpine"
style:
BUILD: style
EXTRA_SUFFIX: ""
pedantic:
BUILD: pedantic
STACK_YAML: stack.yaml
EXTRA_SUFFIX: ""
steps:
- script: |
export STACK_ROOT="$(Build.SourcesDirectory)"/.stack-root;
mkdir -p ~/.local/bin
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
tar xzf ~/.local/bin/cache-s3.tar.gz -C ~/.local/bin
export PATH=$HOME/.local/bin:$PATH;
cache-s3 --prefix="${CACHE_S3_PREFIX}" --git-branch="$(Build.SourceBranchName)" --suffix="${OS_NAME}" restore stack --base-branch="${BASE_BRANCH}"
cache-s3 --prefix="${CACHE_S3_PREFIX}" --git-branch="$(Build.SourceBranchName)" --suffix="${OS_NAME}" restore stack work --base-branch="${BASE_BRANCH}"
cache-s3 --prefix="${CACHE_S3_PREFIX}" --git-branch="$(Build.SourceBranchName)" --suffix="${OS_NAME}${EXTRA_SUFFIX}" restore stack --base-branch="${BASE_BRANCH}"
cache-s3 --prefix="${CACHE_S3_PREFIX}" --git-branch="$(Build.SourceBranchName)" --suffix="${OS_NAME}${EXTRA_SUFFIX}" restore stack work --base-branch="${BASE_BRANCH}"
etc/scripts/ci-setup.sh
case "$BUILD" in
style)
Expand All @@ -38,7 +47,7 @@ jobs:
;;
*)
export PATH=$HOME/.local/bin:$PATH
stack --install-ghc $ARGS test --bench --only-dependencies
stack $ARGS test --bench --only-dependencies
;;
esac
GHC_OPTIONS="-Werror"
Expand All @@ -51,7 +60,11 @@ jobs:
hlint test/ --cpp-simple
;;
stack)
stack test --haddock --no-haddock-deps --ghc-options="$GHC_OPTIONS"
stack test --haddock --no-haddock-deps --ghc-options="$GHC_OPTIONS" --copy-bins --local-bin-path bin
# Make sure Alpine actually builds a static exe that works on Ubuntu
./bin/stack --version
ldd ./bin/stack || true # ldd returns exit code 1 on statics, which we don't want to fail for
;;
pedantic)
stack --system-ghc build --pedantic
Expand Down Expand Up @@ -94,9 +107,9 @@ jobs:
export AWS_SECRET_ACCESS_KEY="$(AWS_SECRET_ACCESS_KEY)";
export STACK_ROOT="$(Build.SourcesDirectory)"/.stack-root;
if [ "$(Build.SourceBranchName)" = "${BASE_BRANCH}" ]; then
cache-s3 --prefix="${CACHE_S3_PREFIX}" --git-branch="$(Build.SourceBranchName)" --suffix="${OS_NAME}" save stack;
cache-s3 --prefix="${CACHE_S3_PREFIX}" --git-branch="$(Build.SourceBranchName)" --suffix="${OS_NAME}${EXTRA_SUFFIX}" save stack;
fi;
cache-s3 --prefix="${CACHE_S3_PREFIX}" --git-branch="$(Build.SourceBranchName)" --suffix="${OS_NAME}" save stack work
cache-s3 --prefix="${CACHE_S3_PREFIX}" --git-branch="$(Build.SourceBranchName)" --suffix="${OS_NAME}${EXTRA_SUFFIX}" save stack work
condition: and(succeeded(), in(variables['Build.Reason'], 'IndividualCI', 'BatchedCI'))
env:
OS_NAME: ${{ parameters.os }}
Expand Down
1 change: 1 addition & 0 deletions .azure/azure-nightly-template-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ jobs:
OS_NAME: ${{ parameters.os }}
AWS_ACCESS_KEY_ID: $(AWS_ACCESS_KEY_ID)
AWS_SECRET_ACCESS_KEY: $(AWS_SECRET_ACCESS_KEY)
STACK_YAML: $(Build.SourcesDirectory)/stack-alpine.yaml
displayName: 'Installation ${{parameters.os}}'
- script: |
set -ex
Expand Down
30 changes: 30 additions & 0 deletions stack-alpine.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
resolver: lts-14.27

packages:
- .

docker:
enable: true
#repo: fpco/alpine-haskell-stack:8.6.5
repo: fpco/alpine-haskell-stack@sha256:665495cf78a9a7a667a45061a1322989b128d3443d87821fac1445dc85984804

flags:
stack:
hide-dependency-versions: true
supported-build: true

ghc-options:
"$locals": -fhide-source-paths -optl-static

extra-deps:
- Cabal-3.0.0.0@rev:0
- hpack-0.33.0@rev:0
- http-download-0.2.0.0@rev:0
- filelock-0.1.1.4@rev:0
- pantry-0.4.0.1@rev:0
- casa-client-0.0.1@rev:0
- casa-types-0.0.1@rev:0

drop-packages:
# See https://github.com/commercialhaskell/stack/pull/4712
- cabal-install

0 comments on commit 2db6983

Please sign in to comment.