Skip to content

Commit 79da6fc

Browse files
committed
feat: use blinklabs-io/haskell image for adversary
Blink Labs maintains both amd64 and arm64 variants of a Haskell builder image including all of the prerequisite libraries for building on Cardano such as libsecp256kp1 and BLST. This reduces the compilation times significantly. Also, it restores ARM support for Docker Desktop users on MacOS without using emulation. Signed-off-by: Chris Gianelloni <[email protected]>
1 parent 6538323 commit 79da6fc

File tree

2 files changed

+5
-99
lines changed

2 files changed

+5
-99
lines changed

adversary/Dockerfile

Lines changed: 5 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -1,103 +1,12 @@
1-
FROM docker.io/debian@sha256:8810492a2dd16b7f59239c1e0cc1e56c1a1a5957d11f639776bd6798e795608b AS build
1+
FROM ghcr.io/blinklabs-io/haskell:9.6.6-3.12.1.0-1 AS build
22

3-
ARG BLST_VERSION="${BLST_VERSION:-0.3.11}"
4-
ARG BOOTSTRAP_HASKELL_CABAL_VERSION="${BOOTSTRAP_HASKELL_CABAL_VERSION:-3.12.1.0}"
5-
ARG BOOTSTRAP_HASKELL_GHC_VERSION="${BOOTSTRAP_HASKELL_GHC_VERSION:-9.6.7}"
6-
ARG CARDANO_CLI_VERSION="${CARDANO_CLI_VERSION:-10.5.0.0}"
7-
ARG CARDANO_NODE_REF="${CARDANO_NODE_REF:-10.2.1}"
8-
ARG CARDANO_NODE_REPO="${CARDANO_NODE_REPO:-https://github.com/IntersectMBO/cardano-node.git}"
9-
ARG JOBS="${JOBS:-8}"
10-
ARG LIBSODIUM_VERSION="${LIBSODIUM_VERSION:-dbb48cc}"
11-
ARG SECP256K1_VERSION="${SECP256K1_VERSION:-ac83be33}"
12-
ARG UV_VERSION="${UV_VERSION:-0.6.11}"
3+
ARG JOBS=8
134

145
# Set time zone
156
ENV TZ="UTC"
167
RUN ln -snf /usr/share/zoneinfo/${TZ} /etc/localtime && \
178
echo ${TZ} > /etc/timezone
189

19-
# Install packages required in build stage
20-
RUN apt update && \
21-
apt install -y --no-install-recommends \
22-
autoconf \
23-
automake \
24-
build-essential \
25-
ca-certificates \
26-
curl \
27-
g++ \
28-
git \
29-
gnupg \
30-
libffi-dev \
31-
libgmp-dev \
32-
liblmdb-dev \
33-
libncurses-dev \
34-
libssl-dev \
35-
libsystemd-dev \
36-
libtinfo-dev \
37-
libtool \
38-
pkg-config \
39-
tar \
40-
zlib1g-dev
41-
42-
# Install GHCup
43-
RUN curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | sh
44-
45-
# Activate GHCup
46-
RUN ln -s /root/.ghcup/bin/cabal-${BOOTSTRAP_HASKELL_CABAL_VERSION} /usr/local/bin/cabal && \
47-
ln -s /root/.ghcup/ghc/${BOOTSTRAP_HASKELL_GHC_VERSION}/bin/ghc-${BOOTSTRAP_HASKELL_GHC_VERSION} /usr/local/bin/ghc
48-
49-
# Clone libsodium.git repository
50-
WORKDIR /usr/local/src
51-
RUN git clone --branch master https://github.com/IntersectMBO/libsodium.git
52-
53-
# Build libsodium
54-
WORKDIR /usr/local/src/libsodium
55-
RUN git checkout ${LIBSODIUM_VERSION} && \
56-
./autogen.sh && \
57-
./configure && \
58-
make && \
59-
make check && \
60-
make install -j${JOBS}
61-
62-
# Clone secp256k1.git repository
63-
WORKDIR /usr/local/src
64-
RUN git clone --branch master https://github.com/bitcoin-core/secp256k1.git
65-
66-
# Build secp256k1
67-
WORKDIR /usr/local/src/secp256k1
68-
RUN git checkout ${SECP256K1_VERSION} && \
69-
./autogen.sh && \
70-
./configure --prefix=/usr --enable-module-schnorrsig --enable-experimental && \
71-
make && \
72-
make check && \
73-
make install -j${JOBS}
74-
75-
# Clone blst.git repository
76-
WORKDIR /usr/local/src
77-
RUN git clone --branch master https://github.com/supranational/blst.git
78-
79-
# Build blst
80-
WORKDIR /usr/local/src/blst
81-
RUN git checkout v${BLST_VERSION} && \
82-
./build.sh
83-
RUN echo "prefix=/usr/local\n\
84-
exec_prefix=/usr/local\n\
85-
libdir=/usr/local/lib\n\
86-
includedir=/usr/local/include\n\
87-
\n\
88-
Name: libblst\n\
89-
Description: Multilingual BLS12-381 signature library\n\
90-
URL: https://github.com/supranational/blst\n\
91-
Version: ${BLST_VERSION}\n\
92-
Cflags: -I/usr/local/include\n\
93-
Libs: -L/usr/local/lib -lblst" >/usr/local/src/blst/libblst.pc
94-
95-
RUN mv /usr/local/src/blst/libblst.pc /usr/local/lib/pkgconfig/ && \
96-
mv /usr/local/src/blst/bindings/blst.h /usr/local/include/ && \
97-
mv /usr/local/src/blst/bindings/blst.hpp /usr/local/include/ && \
98-
mv /usr/local/src/blst/bindings/blst_aux.h /usr/local/include/ && \
99-
mv /usr/local/src/blst/libblst.a /usr/local/lib
100-
10110
# Update path environment variables
10211
ENV LD_LIBRARY_PATH="/usr/local/lib:$LD_LIBRARY_PATH" \
10312
PKG_CONFIG_PATH="/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH"
@@ -109,8 +18,8 @@ RUN --mount=type=cache,target=/root/.local/state/cabal/store \
10918
--mount=type=cache,target=/root/.cache/cabal \
11019
--mount=type=cache,target=./dist-newstyle \
11120
cabal update && \
112-
cabal install --install-method=copy
113-
RUN cp /root/.cabal/bin/adversary /usr/local/bin/
21+
cabal build all && \
22+
cp -p dist-newstyle/build/$(uname -m)-linux/ghc-${GHC_VERSION}/adversary-0.1.0.0/x/adversary/build/adversary/adversary /usr/local/bin/
11423

11524
#---------------------------------------------------------------------
11625

@@ -131,7 +40,7 @@ RUN ln -snf /usr/local/lib/libsodium.so /usr/local/lib/libsodium.so.23 && \
13140
RUN ldconfig
13241

13342
# Copy secp256k1 library
134-
COPY --from=build --chown=root:root /usr/local/src/secp256k1/.libs/libsecp256k1.so /usr/local/lib
43+
COPY --from=build --chown=root:root /usr/local/lib/libsecp256k1.so /usr/local/lib
13544
RUN ln -snf /usr/local/lib/libsecp256k1.so /usr/local/lib/libsecp256k1.so.1 && \
13645
ln -snf /usr/local/lib/libsecp256k1.so /usr/local/lib/libsecp256k1.so.1.0.1
13746
RUN ldconfig

compose/Makefile

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@ testnet:=cardano_node_master
1010
url:=https://cardano.antithesis.com/api/v1/launch/cardano
1111
username:=cardano
1212

13-
# Required for builds on OSX ARM
14-
export DOCKER_DEFAULT_PLATFORM?=linux/amd64
15-
1613
export registry
1714

1815
help:

0 commit comments

Comments
 (0)