Skip to content

Commit f7823c8

Browse files
authored
Merge pull request #53 from AlistairB/travis-arm
Add ARM64 processor architecture support
2 parents 24ba1b0 + 4b9bee3 commit f7823c8

File tree

13 files changed

+410
-389
lines changed

13 files changed

+410
-389
lines changed

.github/workflows/ci.yml

+67-5
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
1-
name: Build and Smoke Test
1+
name: Validate Docker
22

33
on:
44
pull_request:
55
branches:
66
- master
7+
paths:
8+
- '**/Dockerfile'
9+
- '.github/workflows/**'
710

811
jobs:
9-
ci:
12+
build-smoke-test:
1013
timeout-minutes: 30
11-
runs-on: ubuntu-18.04
14+
runs-on: ubuntu-latest
1215
name: ${{ matrix.ghc }}-${{ matrix.deb }}
1316
strategy:
1417
fail-fast: false
@@ -24,8 +27,8 @@ jobs:
2427
ghc_minor: '9.2'
2528
steps:
2629
- uses: actions/checkout@v2
27-
- name: docker build [${{ matrix.ghc }}]
28-
uses: nick-invision/retry@v1
30+
- name: build + smoke test [${{ matrix.ghc }}]
31+
uses: nick-invision/retry@v2
2932
with:
3033
timeout_minutes: 8
3134
max_attempts: 3
@@ -39,3 +42,62 @@ jobs:
3942
path: official-images
4043
- name: run official-images tests
4144
run: ./official-images/test/run.sh haskell:${{ matrix.ghc }}-${{ matrix.deb }}
45+
46+
hadolint:
47+
runs-on: ubuntu-latest
48+
steps:
49+
- uses: actions/checkout@v2
50+
- uses: hadolint/[email protected]
51+
with:
52+
recursive: true
53+
54+
emulated-architecture-tests:
55+
timeout-minutes: 60
56+
runs-on: ubuntu-latest
57+
name: ${{ matrix.arch }}-${{ matrix.ghc }}-${{ matrix.deb }}
58+
strategy:
59+
fail-fast: false
60+
matrix:
61+
ghc: ['8.10.7', '9.0.2', '9.2.1']
62+
deb: ['buster']
63+
arch: ['aarch64']
64+
include:
65+
- ghc: '8.10.7'
66+
ghc_minor: '8.10'
67+
- ghc: '9.0.2'
68+
ghc_minor: '9.0'
69+
- ghc: '9.2.1'
70+
ghc_minor: '9.2'
71+
- arch: aarch64
72+
docker_platform: arm64
73+
steps:
74+
- uses: actions/checkout@v2
75+
- name: docker build [ ${{ matrix.arch }} ${{ matrix.ghc }}]
76+
uses: uraimo/run-on-arch-action@e9117b926d001f8683802c315b5a134f8c5da3d3
77+
with:
78+
arch: ${{ matrix.arch }}
79+
distro: ${{ matrix.deb }}
80+
githubToken: ${{ github.token }}
81+
dockerRunArgs:
82+
--volume /var/run/docker.sock:/var/run/docker.sock
83+
install: |
84+
apt-get update
85+
apt-get install -y curl
86+
curl -fsSL https://get.docker.com | sh
87+
run: |
88+
docker build --pull \
89+
--platform "linux/${{ matrix.docker_platform }}" \
90+
-t haskell:${{ matrix.ghc }}-${{ matrix.deb }} \
91+
${{ matrix.ghc_minor }}/${{ matrix.deb }}
92+
echo 'testing..'
93+
docker run \
94+
--platform "linux/${{ matrix.docker_platform }}" \
95+
-t haskell:${{ matrix.ghc }}-${{ matrix.deb }} \
96+
bash -c "cabal update && cabal install --lib hashable"
97+
docker run \
98+
--platform "linux/${{ matrix.docker_platform }}" \
99+
-t haskell:${{ matrix.ghc }}-${{ matrix.deb }} \
100+
bash -c "echo | ghci"
101+
102+
# Running the official tests does not work as we need to hardcode the plaform due to the emulated nature.
103+
# This solution is fairly hacky, but gets us most of benefit of the official tests.

.hadolint.yaml

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
ignored:
2+
# https://github.com/hadolint/hadolint/wiki/DL3008
3+
# Don't want to micro manage the dependency versions.
4+
- DL3008
5+
# https://github.com/hadolint/hadolint/wiki/DL3003
6+
# Using cd /tmp is a very convenient way to clean up after a step.
7+
- DL3003
8+
# https://github.com/hadolint/hadolint/wiki/DL4006
9+
# The set -eux; pattern is common in many of the official images. It likely is a better approach here.
10+
- DL4006

7.10/Dockerfile

-22
This file was deleted.

7.8/Dockerfile

-18
This file was deleted.

8.0/Dockerfile

-25
This file was deleted.

8.10/buster/Dockerfile

+116-41
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,15 @@ RUN apt-get update && \
77
apt-get install -y --no-install-recommends \
88
ca-certificates \
99
curl \
10+
dpkg-dev \
1011
git \
1112
gcc \
1213
gnupg \
1314
g++ \
1415
libc6-dev \
1516
libffi-dev \
1617
libgmp-dev \
18+
libnuma-dev \
1719
libsqlite3-dev \
1820
libtinfo-dev \
1921
make \
@@ -25,56 +27,129 @@ RUN apt-get update && \
2527

2628
ARG CABAL_INSTALL=3.6.2.0
2729
ARG CABAL_INSTALL_RELEASE_KEY=A970DF3AC3B9709706D74544B3D9F94B8DCAE210
28-
# get from https://downloads.haskell.org/~cabal/cabal-install-$CABAL_INSTALL/SHA256SUMS
29-
ARG CABAL_INSTALL_RELEASE_SHA256=4759B56E9257E02F29FA374A6B25D6CB2F9D80C7E3A55D4F678A8E570925641C
3030

31-
RUN cd /tmp && \
32-
export GNUPGHOME="$(mktemp -d)" && \
33-
gpg --batch --keyserver keyserver.ubuntu.com --recv-keys ${CABAL_INSTALL_RELEASE_KEY} && \
34-
curl -fSLO https://downloads.haskell.org/~cabal/cabal-install-$CABAL_INSTALL/SHA256SUMS && \
35-
curl -fSLO https://downloads.haskell.org/~cabal/cabal-install-$CABAL_INSTALL/SHA256SUMS.sig && \
36-
gpg --batch --trusted-key B3D9F94B8DCAE210 --verify SHA256SUMS.sig SHA256SUMS && \
37-
curl -fSL https://downloads.haskell.org/~cabal/cabal-install-$CABAL_INSTALL/cabal-install-$CABAL_INSTALL-x86_64-linux-deb10.tar.xz -o cabal-install.tar.gz && \
38-
echo "$CABAL_INSTALL_RELEASE_SHA256 cabal-install.tar.gz" | sha256sum --strict --check && \
39-
tar -xf cabal-install.tar.gz -C /usr/local/bin && \
40-
rm -rf "$GNUPGHOME" /var/lib/apt/lists/* /tmp/*
31+
RUN set -eux; \
32+
cd /tmp; \
33+
ARCH="$(dpkg-architecture --query DEB_BUILD_GNU_CPU)"; \
34+
CABAL_INSTALL_URL="https://downloads.haskell.org/~cabal/cabal-install-$CABAL_INSTALL/cabal-install-$CABAL_INSTALL-$ARCH-linux-deb10.tar.xz"; \
35+
CABAL_INSTALL_SHA256SUMS_URL="https://downloads.haskell.org/~cabal/cabal-install-$CABAL_INSTALL/SHA256SUMS"; \
36+
# sha256 from https://downloads.haskell.org/~cabal/cabal-install-$CABAL_INSTALL/SHA256SUMS
37+
case "$ARCH" in \
38+
'aarch64') \
39+
CABAL_INSTALL_SHA256='d9acee67d4308bc5c22d27bee034d388cc4192a25deff9e7e491e2396572b030'; \
40+
;; \
41+
'x86_64') \
42+
CABAL_INSTALL_SHA256='4759b56e9257e02f29fa374a6b25d6cb2f9d80c7e3a55d4f678a8e570925641c'; \
43+
;; \
44+
*) echo >&2 "error: unsupported architecture '$ARCH'"; exit 1 ;; \
45+
esac; \
46+
curl -fSL "$CABAL_INSTALL_URL" -o cabal-install.tar.gz; \
47+
echo "$CABAL_INSTALL_SHA256 cabal-install.tar.gz" | sha256sum --strict --check; \
48+
\
49+
curl -sSLO "$CABAL_INSTALL_SHA256SUMS_URL"; \
50+
curl -sSLO "$CABAL_INSTALL_SHA256SUMS_URL.sig"; \
51+
GNUPGHOME="$(mktemp -d)"; export GNUPGHOME; \
52+
gpg --batch --keyserver keyserver.ubuntu.com --receive-keys "$CABAL_INSTALL_RELEASE_KEY"; \
53+
gpg --batch --verify SHA256SUMS.sig SHA256SUMS; \
54+
gpgconf --kill all; \
55+
\
56+
tar -xf cabal-install.tar.gz -C /usr/local/bin; \
57+
\
58+
rm -rf /tmp/*; \
59+
\
60+
cabal --version
61+
62+
# GHC 8.10 requires LLVM version 9 - 12 on aarch64
63+
ARG LLVM_VERSION=12
64+
65+
RUN set -eux; \
66+
if [ "$(dpkg-architecture --query DEB_BUILD_GNU_CPU)" = "aarch64" ]; then \
67+
# adapted from https://apt.llvm.org/llvm.sh
68+
curl -sSL https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add -; \
69+
echo "deb http://apt.llvm.org/buster/ llvm-toolchain-buster-$LLVM_VERSION main" > /etc/apt/sources.list.d/llvm.list; \
70+
apt-get update; \
71+
apt-get install -y --no-install-recommends llvm-$LLVM_VERSION; \
72+
rm -rf /var/lib/apt/lists/*; \
73+
fi
4174

4275
ARG GHC=8.10.7
4376
ARG GHC_RELEASE_KEY=88B57FCF7DB53B4DB3BFA4B1588764FBE22D19C4
44-
# get from https://downloads.haskell.org/~ghc/$GHC/SHA256SUMS
45-
ARG GHC_RELEASE_SHA256=A13719BCA87A0D3AC0C7D4157A4E60887009A7F1A8DBE95C4759EC413E086D30
4677

47-
RUN cd /tmp && \
48-
export GNUPGHOME="$(mktemp -d)" && \
49-
curl -sSL https://downloads.haskell.org/~ghc/$GHC/ghc-$GHC-x86_64-deb10-linux.tar.xz -o ghc.tar.xz && \
50-
curl -sSL https://downloads.haskell.org/~ghc/$GHC/ghc-$GHC-x86_64-deb10-linux.tar.xz.sig -o ghc.tar.xz.sig && \
51-
gpg --batch --keyserver keyserver.ubuntu.com --receive-keys ${GHC_RELEASE_KEY} && \
52-
gpg --batch --trusted-key 588764FBE22D19C4 --verify ghc.tar.xz.sig ghc.tar.xz && \
53-
echo "$GHC_RELEASE_SHA256 ghc.tar.xz" | sha256sum --strict --check && \
54-
tar xf ghc.tar.xz && \
55-
cd ghc-$GHC && \
56-
./configure --prefix /opt/ghc/$GHC && \
57-
make install && \
58-
find /opt/ghc/$GHC/ \( -name "*_p.a" -o -name "*.p_hi" \) -type f -delete && \
59-
rm -rf /opt/ghc/$GHC/share/ && \
60-
rm -rf "$GNUPGHOME" /tmp/*
78+
RUN set -eux; \
79+
cd /tmp; \
80+
ARCH="$(dpkg-architecture --query DEB_BUILD_GNU_CPU)"; \
81+
GHC_URL="https://downloads.haskell.org/~ghc/$GHC/ghc-$GHC-$ARCH-deb10-linux.tar.xz"; \
82+
# sha256 from https://downloads.haskell.org/~ghc/$GHC/SHA256SUMS
83+
case "$ARCH" in \
84+
'aarch64') \
85+
GHC_SHA256='fad2417f9b295233bf8ade79c0e6140896359e87be46cb61cd1d35863d9d0e55'; \
86+
;; \
87+
'x86_64') \
88+
GHC_SHA256='a13719bca87a0d3ac0c7d4157a4e60887009a7f1a8dbe95c4759ec413e086d30'; \
89+
;; \
90+
*) echo >&2 "error: unsupported architecture '$ARCH'" ; exit 1 ;; \
91+
esac; \
92+
curl -sSL "$GHC_URL" -o ghc.tar.xz; \
93+
echo "$GHC_SHA256 ghc.tar.xz" | sha256sum --strict --check; \
94+
\
95+
GNUPGHOME="$(mktemp -d)"; export GNUPGHOME; \
96+
curl -sSL "$GHC_URL.sig" -o ghc.tar.xz.sig; \
97+
gpg --batch --keyserver keyserver.ubuntu.com --receive-keys "$GHC_RELEASE_KEY"; \
98+
gpg --batch --verify ghc.tar.xz.sig ghc.tar.xz; \
99+
gpgconf --kill all; \
100+
\
101+
tar xf ghc.tar.xz; \
102+
cd "ghc-$GHC"; \
103+
./configure --prefix "/opt/ghc/$GHC"; \
104+
make install; \
105+
# remove profiling support to save space
106+
find "/opt/ghc/$GHC/" \( -name "*_p.a" -o -name "*.p_hi" \) -type f -delete; \
107+
# remove some docs
108+
rm -rf "/opt/ghc/$GHC/share/"; \
109+
\
110+
rm -rf /tmp/*; \
111+
\
112+
"/opt/ghc/$GHC/bin/ghc" --version
61113

62114
ARG STACK=2.7.3
63115
ARG STACK_RELEASE_KEY=C5705533DA4F78D8664B5DC0575159689BEFB442
64-
# get from https://github.com/commercialhaskell/stack/releases/download/v${STACK}/stack-${STACK}-linux-x86_64.tar.gz.sha256
65-
ARG STACK_RELEASE_SHA256=A6C090555FA1C64AA61C29AA4449765A51D79E870CF759CDE192937CD614E72B
66116

67-
RUN cd /tmp && \
68-
export GNUPGHOME="$(mktemp -d)" && \
69-
gpg --batch --keyserver keyserver.ubuntu.com --recv-keys ${STACK_RELEASE_KEY} && \
70-
curl -fSL https://github.com/commercialhaskell/stack/releases/download/v${STACK}/stack-${STACK}-linux-x86_64.tar.gz -o stack.tar.gz && \
71-
curl -fSL https://github.com/commercialhaskell/stack/releases/download/v${STACK}/stack-${STACK}-linux-x86_64.tar.gz.asc -o stack.tar.gz.asc && \
72-
gpg --batch --trusted-key 575159689BEFB442 --verify stack.tar.gz.asc stack.tar.gz && \
73-
echo "$STACK_RELEASE_SHA256 stack.tar.gz" | sha256sum --strict --check && \
74-
tar -xf stack.tar.gz -C /usr/local/bin --strip-components=1 stack-$STACK-linux-x86_64/stack && \
75-
/usr/local/bin/stack config set system-ghc --global true && \
76-
/usr/local/bin/stack config set install-ghc --global false && \
77-
rm -rf "$GNUPGHOME" /var/lib/apt/lists/* /tmp/*
117+
RUN set -eux; \
118+
cd /tmp; \
119+
ARCH="$(dpkg-architecture --query DEB_BUILD_GNU_CPU)"; \
120+
INSTALL_STACK="true"; \
121+
STACK_URL="https://github.com/commercialhaskell/stack/releases/download/v${STACK}/stack-${STACK}-linux-$ARCH.tar.gz"; \
122+
# sha256 from https://github.com/commercialhaskell/stack/releases/download/v${STACK}/stack-${STACK}-linux-$ARCH.tar.gz.sha256
123+
case "$ARCH" in \
124+
'aarch64') \
125+
# Stack does not officially support ARM64, nor do the binaries that exist work.
126+
# Hitting https://github.com/commercialhaskell/stack/issues/2103#issuecomment-972329065 when trying to use
127+
# stack-2.7.1-linux-aarch64.tar.gz
128+
INSTALL_STACK="false"; \
129+
;; \
130+
'x86_64') \
131+
STACK_SHA256='a6c090555fa1c64aa61c29aa4449765a51d79e870cf759cde192937cd614e72b'; \
132+
;; \
133+
*) echo >&2 "error: unsupported architecture '$ARCH'" ; exit 1 ;; \
134+
esac; \
135+
if [ "$INSTALL_STACK" = "true" ]; then \
136+
curl -sSL "$STACK_URL" -o stack.tar.gz; \
137+
echo "$STACK_SHA256 stack.tar.gz" | sha256sum --strict --check; \
138+
\
139+
curl -sSL "$STACK_URL.asc" -o stack.tar.gz.asc; \
140+
GNUPGHOME="$(mktemp -d)"; export GNUPGHOME; \
141+
gpg --batch --keyserver keyserver.ubuntu.com --receive-keys "$STACK_RELEASE_KEY"; \
142+
gpg --batch --verify stack.tar.gz.asc stack.tar.gz; \
143+
gpgconf --kill all; \
144+
\
145+
tar -xf stack.tar.gz -C /usr/local/bin --strip-components=1 "stack-$STACK-linux-$ARCH/stack"; \
146+
stack config set system-ghc --global true; \
147+
stack config set install-ghc --global false; \
148+
\
149+
rm -rf /tmp/*; \
150+
\
151+
stack --version; \
152+
fi
78153

79154
ENV PATH /root/.cabal/bin:/root/.local/bin:/opt/ghc/${GHC}/bin:$PATH
80155

8.2/Dockerfile

-28
This file was deleted.

0 commit comments

Comments
 (0)