This repository has been archived by the owner on May 6, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 29
/
Dockerfile
120 lines (85 loc) · 3.45 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#
# A multistage approach to building a Cardano Node/CLI image
#
# Some build-arg parameters
ARG CARDANO_VER
ARG CABAL_VER
ARG GHC_VER
ARG ARCH
## Install dependencies and libsodium #################################################################################
FROM debian:10-slim as builderA
ENV DEBIAN_FRONTEND=noninteractive
# Install dependencies
RUN apt-get update \
&& apt-get install -y \
autoconf automake build-essential g++ git jq \
libffi-dev libgmp-dev libncursesw5 libnuma-dev libssl-dev libsystemd-dev libtinfo-dev libtool llvm \
make pkg-config tmux wget zlib1g-dev
# Install Libsodium
WORKDIR /src
RUN git clone https://github.com/input-output-hk/libsodium
WORKDIR libsodium
RUN git checkout 66f017f1
RUN ./autogen.sh \
&& ./configure \
&& make install
ENV LD_LIBRARY_PATH="/usr/local/lib"
ENV PKG_CONFIG_PATH="/usr/local/lib/pkgconfig"
## Build + Install GHC & Cabal ########################################################################################
FROM builderA as builderB
ARG CABAL_VER
ARG GHC_VER
ARG ARCH
# Download and install GHC
WORKDIR /src
RUN wget -q https://downloads.haskell.org/ghc/${GHC_VER}/ghc-${GHC_VER}-${ARCH}-deb10-linux.tar.xz \
&& tar -xf ghc-${GHC_VER}-${ARCH}-deb10-linux.tar.xz
WORKDIR ghc-${GHC_VER}
RUN ./configure \
&& make install
RUN ghc --version
# The Haskell Common Architecture for Building Applications and Libraries
ARG CABAL_TAG="${CABAL_VER}"
WORKDIR /src
RUN if [ "${ARCH}" = "aarch64" ]; then \
wget -q https://downloads.haskell.org/~cabal/cabal-install-${CABAL_TAG}/cabal-install-${CABAL_VER}-aarch64-ubuntu-18.04.tar.xz \
&& tar -xf cabal-install-${CABAL_VER}-aarch64-ubuntu-18.04.tar.xz; \
elif [ "${ARCH}" = "x86_64" ]; then \
wget -q https://downloads.haskell.org/~cabal/cabal-install-${CABAL_TAG}/cabal-install-${CABAL_VER}-x86_64-ubuntu-16.04.tar.xz \
&& tar -xf cabal-install-${CABAL_VER}-x86_64-ubuntu-16.04.tar.xz; \
fi
RUN mv cabal /usr/local/bin/
RUN cabal --version
## Buid Cardano #######################################################################################################
FROM builderB as builderC
ARG CARDANO_VER
ARG CABAL_VER
ARG GHC_VER
ARG ARCH
# Build and install cardano-node
WORKDIR /src
RUN git clone -b $CARDANO_VER --depth 1 https://github.com/input-output-hk/cardano-node.git
WORKDIR cardano-node
RUN cabal update \
&& cabal configure
RUN echo "package cardano-crypto-praos" >> cabal.project.local
RUN echo " flags: -external-libsodium-vrf" >> cabal.project.local
RUN echo "" >> cabal.project.local
# Can no longer build cardano-node on arm64
# https://github.com/input-output-hk/cardano-node/issues/3395
RUN echo "package trace-dispatcher" >> cabal.project.local
RUN echo " ghc-options: -Wwarn" >> cabal.project.local
RUN echo "" >> cabal.project.local
RUN cat cabal.project.local \
&& cabal build all
RUN cp $(find ./dist-newstyle/build -type f -name "cardano-node") /usr/local/bin/
RUN cp $(find ./dist-newstyle/build -type f -name "cardano-cli") /usr/local/bin/
RUN cp $(find ./dist-newstyle/build -type f -name "cardano-submit-api") /usr/local/bin/
WORKDIR /root
## Buid Cardano #######################################################################################################
FROM builderA
# Copy the executables from the previous build
COPY --from=builderC /usr/local/bin/cardano-node /usr/local/bin/
COPY --from=builderC /usr/local/bin/cardano-cli /usr/local/bin/
COPY --from=builderC /usr/local/bin/cardano-submit-api /usr/local/bin/
WORKDIR /