Dockerfile 4.02 KB
Newer Older
1
2
FROM debian:latest AS build
LABEL maintainer="VIPER Staking Team (viperstakepool@gmail.com)"
3
4

# Update and install the required packages
Dylan Crocker's avatar
Dylan Crocker committed
5
ARG DEBIAN_FRONTEND=noninteractive
6
RUN apt-get update && apt-get install -y \
Dylan Crocker's avatar
Dylan Crocker committed
7
  automake \
8
9
10
11
12
13
14
15
16
17
18
19
20
21
  build-essential \
  pkg-config \
  libffi-dev \
  libgmp-dev \
  libssl-dev \
  libtinfo-dev \
  libsystemd-dev \
  zlib1g-dev \
  make \
  g++ \
  tmux \
  git \
  jq \
  wget \
22
23
  libncursesw5 \
  libtool \
24
25
  autoconf \
  curl
26

27
# Build and install the IOHK fork of libsodium.
28
WORKDIR /opt
29
30
31
32
33
RUN git clone https://github.com/input-output-hk/libsodium \
  && cd libsodium \
  && git checkout 66f017f1 \
  && ./autogen.sh \
  && ./configure \
Dylan Crocker's avatar
Dylan Crocker committed
34
  && make -j16 \
35
36
37
38
  && make install
ENV LD_LIBRARY_PATH="/usr/local/lib:$LD_LIBRARY_PATH"
ENV PKG_CONFIG_PATH="/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH"

39
# Install cabal
40
41
42
43
WORKDIR /opt
RUN wget https://downloads.haskell.org/~cabal/cabal-install-3.4.1.0/cabal-install-3.4.1.0-x86_64-linux-deb10.tar.xz \
  && tar -xf cabal-install-3.4.1.0-x86_64-linux-deb10.tar.xz \
  && rm cabal-install-3.4.1.0-x86_64-linux-deb10.tar.xz \
Dylan Crocker's avatar
Dylan Crocker committed
44
45
  && mv cabal /usr/local/bin/ \
  && cabal update
46
47

# Install GHC
48
49
50
51
52
WORKDIR /opt
RUN wget https://downloads.haskell.org/ghc/8.10.7/ghc-8.10.7-x86_64-deb9-linux.tar.xz \
  && tar -xf ghc-8.10.7-x86_64-deb9-linux.tar.xz \
  && rm ghc-8.10.7-x86_64-deb9-linux.tar.xz \
  && cd ghc-8.10.7 \
53
  && ./configure \
Dylan Crocker's avatar
Dylan Crocker committed
54
  && make install
55

56
57
58
# Build and install cardano node
WORKDIR /opt
ARG TAG=1.33.0
59
60
RUN git clone https://github.com/input-output-hk/cardano-node.git \
  && cd cardano-node \
Dylan Crocker's avatar
Dylan Crocker committed
61
62
  && git fetch --all --recurse-submodules --tags \
  && git tag && git checkout tags/$TAG \
63
  && cabal configure --with-compiler=ghc-8.10.7 \
Dylan Crocker's avatar
Dylan Crocker committed
64
65
66
  && echo "package cardano-crypto-praos" >>  cabal.project.local \
  && echo "  flags: -external-libsodium-vrf" >>  cabal.project.local \
  && cabal build -j16 all \
Dylan Crocker's avatar
Dylan Crocker committed
67
  && mkdir /opt/bin/ \
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
  && cp -p dist-newstyle/build/x86_64-linux/ghc-8.10.7/cardano-node-$TAG/x/cardano-node/build/cardano-node/cardano-node /opt/bin/ \
  && cp -p dist-newstyle/build/x86_64-linux/ghc-8.10.7/cardano-cli-$TAG/x/cardano-cli/build/cardano-cli/cardano-cli /opt/bin/

# Install Rust
WORKDIR /opt
RUN mkdir -p $HOME/.cargo/bin \
 && curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
ENV PATH="/root/.cargo/bin:${PATH}"
RUN rustup install stable && rustup default stable && rustup update \
 && rustup component add clippy rustfmt

# Build and install CNCLI
WORKDIR /opt
ARG CNCLI_TAG=v4.0.4
RUN git clone --recurse-submodules https://github.com/AndrewWestberg/cncli \
 && cd cncli \
 && git checkout $CNCLI_TAG \
 && cargo install --path . --force \
 && cncli --version
87

88
89
90
# Install Prometheus Node Exporter
ARG VERSION=1.0.1
ARG DIRNAME="node_exporter-$VERSION.linux-amd64"
91
92
WORKDIR /opt
RUN wget https://github.com/prometheus/node_exporter/releases/download/v$VERSION/$DIRNAME.tar.gz \
93
94
95
  && tar xvfz $DIRNAME.tar.gz \
  && mv $DIRNAME/node_exporter /usr/local/bin

96
97
# Build the final stage and copy the build artifacts from the previous stage.
FROM registry.gitlab.com/viper-staking/docker-containers/debian-base:latest
98
COPY --from=build /usr/local/lib/libsodium* /usr/local/lib/
Dylan Crocker's avatar
Dylan Crocker committed
99
100
COPY --from=build /opt/bin/cardano-cli /usr/local/bin/
COPY --from=build /opt/bin/cardano-node /usr/local/bin/
101
COPY --from=build /usr/local/bin/node_exporter /usr/local/bin
102
103
COPY --from=build /root/.cargo/bin/cncli /usr/local/bin
COPY --from=build /opt/cncli/scripts/ /root/scripts
104
105
ENV LD_LIBRARY_PATH="/usr/local/lib:$LD_LIBRARY_PATH"
ENV PKG_CONFIG_PATH="/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH"
106

107
108
109
# Copy over other resources from the build context.
COPY entrypoint.sh /usr/local/bin/

110
111
# Create a directory for the node config files and blockchain database. 
# This needs to be mounted to a host volume on container run.
112
USER lovelace
113
RUN mkdir ${HOME}/cardano-node/
Willie Marchetto's avatar
Willie Marchetto committed
114

115
# Clone the cardano-tools repo
Dylan Crocker's avatar
Dylan Crocker committed
116
RUN python3 -m pip install cardano-tools
117

118
119
120
121
# Expose prometheus monitoring ports
EXPOSE 9100
EXPOSE 12798

122
# Set cardano-node as the entrypoint and by default just print the version.
123
ENTRYPOINT ["entrypoint.sh"]
Dylan Crocker's avatar
Dylan Crocker committed
124
CMD ["--version"]