forked from Taraxa-project/taraxa-node
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
135 lines (109 loc) · 4.11 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
134
135
# Default output dir containing build artifacts
ARG BUILD_OUTPUT_DIR=cmake-docker-build-debug
#############################################
# builder image - contains all dependencies #
#############################################
FROM amd64/ubuntu:20.04 as builder
# deps versions
ARG GO_VERSION=1.16.3
ARG CMAKE_VERSION=3.16.3-1ubuntu1
ARG GFLAGS_VERSION=2.2.2-1build1
ARG LLVM_VERSION=12
# 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 \
software-properties-common \
&& rm -rf /var/lib/apt/lists/*
# Install LLVM
RUN curl -SL -o llvm.sh https://apt.llvm.org/llvm.sh && \
chmod +x llvm.sh && \
./llvm.sh $LLVM_VERSION && \
rm -f llvm.sh
# To get Solidity compiler for python integration tests
# 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 \
ca-certificates \
libtool \
autoconf \
binutils \
cmake=$CMAKE_VERSION \
ccache \
libgflags-dev=$GFLAGS_VERSION \
solc \
&& rm -rf /var/lib/apt/lists/*
ENV CXX="clang++-${LLVM_VERSION}"
ENV CC="clang-${LLVM_VERSION}"
# Install conan
RUN pip3 install --upgrade conan
# Install go
RUN curl -SL https://dl.google.com/go/go$GO_VERSION.linux-amd64.tar.gz \
| tar -xzC /usr/local
# Add go to PATH
ENV GOROOT=/usr/local/go
ENV GOPATH=$HOME/.go
ENV PATH=$GOPATH/bin:$GOROOT/bin:$PATH
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:20.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"]