Skip to content

Commit d7b9eb0

Browse files
authored
Merge pull request #2281 from GaloisInc/T2279-Dockerfile-ARM64
Dockerfiles: Support both amd64 and arm64 builds
2 parents a79c89b + ae141b5 commit d7b9eb0

File tree

2 files changed

+56
-12
lines changed

2 files changed

+56
-12
lines changed

saw-remote-api/Dockerfile

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ RUN apt-get update && \
44
apt-get install -y \
55
# ghcup requirements
66
build-essential curl libffi-dev libffi8 libgmp-dev libgmp10 libncurses-dev libncurses6 libtinfo6 \
7+
# Although ghcup's version of GHC shouldn't require libnuma, the aarch64 \
8+
# version does impose this requirement for unknown reasons. \
9+
# (See https://gitlab.haskell.org/ghc/ghc/-/issues/20876#note_399802) \
10+
libnuma1 \
711
# SAW dependencies
812
pkg-config zlib1g-dev \
913
# Miscellaneous
@@ -16,8 +20,18 @@ ENV LANG=C.UTF-8 \
1620
LC_ALL=C.UTF-8
1721
COPY cabal.GHC-9.4.8.config cabal.project.freeze
1822
ENV PATH=/home/saw/ghcup-download/bin:/home/saw/.ghcup/bin:$PATH
19-
RUN mkdir -p /home/saw/ghcup-download/bin && \
20-
curl -L https://downloads.haskell.org/~ghcup/0.1.19.5/x86_64-linux-ghcup-0.1.19.5 -o /home/saw/ghcup-download/bin/ghcup && \
23+
ARG TARGETPLATFORM
24+
RUN case ${TARGETPLATFORM} in \
25+
"linux/amd64") \
26+
GHCUP_ARCH=x86_64 ;; \
27+
"linux/arm64" | "linux/arm64/v8") \
28+
GHCUP_ARCH=aarch64 ;; \
29+
*) \
30+
printf "Unsupported architecture: %s\n" "${TARGETPLATFORM}" >&2 \
31+
exit 1 ;; \
32+
esac && \
33+
mkdir -p /home/saw/ghcup-download/bin && \
34+
curl -L https://downloads.haskell.org/~ghcup/0.1.19.5/${GHCUP_ARCH}-linux-ghcup-0.1.19.5 -o /home/saw/ghcup-download/bin/ghcup && \
2135
chmod +x /home/saw/ghcup-download/bin/ghcup
2236
RUN mkdir -p /home/saw/.ghcup && \
2337
ghcup --version && \
@@ -26,13 +40,21 @@ RUN mkdir -p /home/saw/.ghcup && \
2640
ghcup set ghc 9.4.8
2741
RUN cabal v2-update && cabal v2-build -j exe:saw-remote-api
2842
RUN mkdir -p /home/saw/rootfs/usr/local/bin
29-
RUN cp $(cabal v2-exec which saw-remote-api) /home/saw/rootfs/usr/local/bin/saw-remote-api
43+
RUN cp $(cabal -v0 list-bin exe:saw-remote-api) /home/saw/rootfs/usr/local/bin/saw-remote-api
3044
WORKDIR /home/saw//rootfs/usr/local/bin
3145
# The URL here is based on the same logic used to specify BUILD_TARGET_OS and
32-
# BUILD_TARGET_ARCH in `.github/workflow/ci.yml`, but specialized to x86-64
33-
# Ubuntu.
46+
# BUILD_TARGET_ARCH in `.github/workflow/ci.yml`, but specialized to Ubuntu.
3447
# If updating the snapshot version, update ci.yml and saw/Dockerfile too.
35-
RUN curl -o solvers.zip -sL "https://github.com/GaloisInc/what4-solvers/releases/download/snapshot-20250326/ubuntu-24.04-X64-bin.zip"
48+
RUN case ${TARGETPLATFORM} in \
49+
"linux/amd64") \
50+
WHAT4_SOLVERS_ARCH=X64 ;; \
51+
"linux/arm64" | "linux/arm64/v8") \
52+
WHAT4_SOLVERS_ARCH=ARM64 ;; \
53+
*) \
54+
printf "Unsupported architecture: %s\n" "${TARGETPLATFORM}" >&2 \
55+
exit 1 ;; \
56+
esac && \
57+
curl -o solvers.zip -sL "https://github.com/GaloisInc/what4-solvers/releases/download/snapshot-20250326/ubuntu-24.04-${WHAT4_SOLVERS_ARCH}-bin.zip"
3658
RUN unzip solvers.zip && rm solvers.zip && chmod +x *
3759
USER root
3860
RUN chown -R root:root /home/saw/rootfs

saw/Dockerfile

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ RUN apt-get update && \
44
apt-get install -y \
55
# ghcup requirements
66
build-essential curl libffi-dev libffi8 libgmp-dev libgmp10 libncurses-dev libncurses6 libtinfo6 \
7+
# Although ghcup's version of GHC shouldn't require libnuma, the aarch64 \
8+
# version does impose this requirement for unknown reasons. \
9+
# (See https://gitlab.haskell.org/ghc/ghc/-/issues/20876#note_399802) \
10+
libnuma1 \
711
# SAW dependencies
812
pkg-config zlib1g-dev \
913
# Miscellaneous
@@ -16,8 +20,18 @@ ENV LANG=C.UTF-8 \
1620
LC_ALL=C.UTF-8
1721
COPY cabal.GHC-9.4.8.config cabal.project.freeze
1822
ENV PATH=/home/saw/ghcup-download/bin:/home/saw/.ghcup/bin:$PATH
19-
RUN mkdir -p /home/saw/ghcup-download/bin && \
20-
curl -L https://downloads.haskell.org/~ghcup/0.1.19.5/x86_64-linux-ghcup-0.1.19.5 -o /home/saw/ghcup-download/bin/ghcup && \
23+
ARG TARGETPLATFORM
24+
RUN case ${TARGETPLATFORM} in \
25+
"linux/amd64") \
26+
GHCUP_ARCH=x86_64 ;; \
27+
"linux/arm64" | "linux/arm64/v8") \
28+
GHCUP_ARCH=aarch64 ;; \
29+
*) \
30+
printf "Unsupported architecture: %s\n" "${TARGETPLATFORM}" >&2 \
31+
exit 1 ;; \
32+
esac && \
33+
mkdir -p /home/saw/ghcup-download/bin && \
34+
curl -L https://downloads.haskell.org/~ghcup/0.1.19.5/${GHCUP_ARCH}-linux-ghcup-0.1.19.5 -o /home/saw/ghcup-download/bin/ghcup && \
2135
chmod +x /home/saw/ghcup-download/bin/ghcup
2236
RUN mkdir -p /home/saw/.ghcup && \
2337
ghcup --version && \
@@ -27,13 +41,21 @@ RUN mkdir -p /home/saw/.ghcup && \
2741
RUN cabal v2-update
2842
RUN cabal v2-build
2943
RUN mkdir -p /home/saw/rootfs/usr/local/bin
30-
RUN cp $(cabal v2-exec which saw) /home/saw/rootfs/usr/local/bin/saw
44+
RUN cp $(cabal -v0 list-bin exe:saw) /home/saw/rootfs/usr/local/bin/saw
3145
WORKDIR /home/saw//rootfs/usr/local/bin
3246
# The URL here is based on the same logic used to specify BUILD_TARGET_OS and
33-
# BUILD_TARGET_ARCH in `.github/workflow/ci.yml`, but specialized to x86-64
34-
# Ubuntu.
47+
# BUILD_TARGET_ARCH in `.github/workflow/ci.yml`, but specialized to Ubuntu.
3548
# If updating the snapshot version, update ci.yml and saw-remote-api/Dockerfile too.
36-
RUN curl -o solvers.zip -sL "https://github.com/GaloisInc/what4-solvers/releases/download/snapshot-20250326/ubuntu-24.04-X64-bin.zip"
49+
RUN case ${TARGETPLATFORM} in \
50+
"linux/amd64") \
51+
WHAT4_SOLVERS_ARCH=X64 ;; \
52+
"linux/arm64" | "linux/arm64/v8") \
53+
WHAT4_SOLVERS_ARCH=ARM64 ;; \
54+
*) \
55+
printf "Unsupported architecture: %s\n" "${TARGETPLATFORM}" >&2 \
56+
exit 1 ;; \
57+
esac && \
58+
curl -o solvers.zip -sL "https://github.com/GaloisInc/what4-solvers/releases/download/snapshot-20250326/ubuntu-24.04-${WHAT4_SOLVERS_ARCH}-bin.zip"
3759
RUN unzip solvers.zip && rm solvers.zip && chmod +x *
3860
USER root
3961
RUN chown -R root:root /home/saw/rootfs

0 commit comments

Comments
 (0)