-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathDockerfile
133 lines (109 loc) · 3.99 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
121
122
123
124
125
126
127
128
129
130
131
132
133
# Default output dir containing build artifacts
ARG BUILD_OUTPUT_DIR=cmake-docker-build-debug
#############################################
# builder image - contains all dependencies #
#############################################
FROM ubuntu:22.04 as builder
# deps versions
ARG LLVM_VERSION=14
# Install standard packages
RUN apt-get update && DEBIAN_FRONTEND=noninteractive \
apt-get install -y --no-install-recommends \
tzdata \
&& apt-get install -y \
tar \
git \
curl \
wget \
python3-pip \
lsb-release \
libgmp-dev \
libmpfr-dev \
software-properties-common \
&& rm -rf /var/lib/apt/lists/*
# install solc for py_test if arch is not arm64 because it is not availiable
RUN \
if [ `arch` != "aarch64" ]; \
then \
add-apt-repository ppa:ethereum/ethereum \
&& apt-get update \
&& apt install solc; \
fi
# install standart tools
RUN add-apt-repository ppa:ethereum/ethereum \
&& apt-get update \
&& apt-get install -y \
clang-format-$LLVM_VERSION \
clang-tidy-$LLVM_VERSION \
llvm-$LLVM_VERSION \
golang-go \
ca-certificates \
libtool \
autoconf \
binutils \
cmake \
ccache \
# this libs are required for arm build by go part
libzstd-dev \
libsnappy-dev \
# replace this with conan dependency
rapidjson-dev \
&& rm -rf /var/lib/apt/lists/*
ENV CXX="clang++-${LLVM_VERSION}"
ENV CC="clang-${LLVM_VERSION}"
# Install conan
RUN pip3 install --upgrade conan
ENV CONAN_REVISIONS_ENABLED=1
# Install conan deps
WORKDIR /opt/taraxa/
COPY conanfile.py .
RUN conan remote add -f bincrafters "https://bincrafters.jfrog.io/artifactory/api/conan/public-conan" \
&& conan profile new clang --detect \
&& conan profile update settings.compiler=clang clang \
&& conan profile update settings.compiler.version=$LLVM_VERSION clang \
&& conan profile update settings.compiler.libcxx=libstdc++11 clang \
&& conan profile update settings.build_type=RelWithDebInfo clang \
&& conan profile update env.CC=clang-$LLVM_VERSION clang \
&& conan profile update env.CXX=clang++-$LLVM_VERSION clang \
&& conan install --build missing -pr=clang .
###################################################################
# Build stage - use builder image for actual build of taraxa node #
###################################################################
FROM builder as build
# Default output dir containing build artifacts
ARG BUILD_OUTPUT_DIR
# Build taraxa-node project
WORKDIR /opt/taraxa/
COPY . .
RUN mkdir $BUILD_OUTPUT_DIR && cd $BUILD_OUTPUT_DIR \
&& cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DTARAXA_ENABLE_LTO=OFF \
-DTARAXA_STATIC_BUILD=OFF \
../ \
&& make -j$(nproc) all \
# Copy CMake generated Testfile to be able to trigger ctest from bin directory
&& cp tests/CTestTestfile.cmake bin/ \
# keep only required shared libraries and final binaries
&& find . -maxdepth 1 ! -name "lib" ! -name "bin" -exec rm -rfv {} \;
###############################################################################
##### Taraxa image containing taraxad binary + dynamic libraries + config #####
###############################################################################
FROM ubuntu:22.04
# Install curl and jq
RUN apt-get update \
&& apt-get install -y curl jq python3 python3-pip \
&& rm -rf /var/lib/apt/lists/*
# Install required Python packages
RUN pip3 install click eth-account eth-utils
ARG BUILD_OUTPUT_DIR
WORKDIR /root/.taraxa
# Copy required binaries
COPY --from=build /opt/taraxa/$BUILD_OUTPUT_DIR/bin/taraxad /usr/local/bin/taraxad
COPY --from=build /opt/taraxa/$BUILD_OUTPUT_DIR/bin/taraxa-bootnode /usr/local/bin/taraxa-bootnode
COPY --from=build /opt/taraxa/$BUILD_OUTPUT_DIR/lib/*.so /usr/local/lib/
# Copy scripts
COPY scripts/taraxa-sign.py /usr/local/bin/taraxa-sign
# Set LD_LIBRARY_PATH so taraxad binary finds shared libs
ENV LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
COPY docker-entrypoint.sh /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]