forked from smartbch/smartbch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile.optimized
90 lines (81 loc) · 3.64 KB
/
Dockerfile.optimized
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
FROM ubuntu:20.04
MAINTAINER Josh Ellithorpe <[email protected]>
ARG SMARTBCH_VERSION="v0.4.2"
ARG MOEINGEVM_VERSION="v0.4.0"
ARG CONFIG_VERSION="v0.0.6"
ARG GOLANG_VERSION="1.17.2"
ARG PATCH_CGO_VERSION="0.1.2"
ARG ROCKSDB_VERSION="5.18.4"
ARG SNAPPY_VERSION="1.1.8"
ARG TARGETPLATFORM
ENV TARGETPLATFORM=${TARGETPLATFORM:-linux/amd64}
ARG SMARTBCH_BUILD_TAGS="cppbtree"
ARG CHAIN_ID="0x2710"
ENV DEBIAN_FRONTEND="noninteractive"
ENV GOROOT=/usr/local/go
ENV GOPATH=/go
ENV PATH=$GOPATH/bin:$GOROOT/bin:$PATH
ENV LD_LIBRARY_PATH=/usr/local/lib
ENV CGO_CFLAGS="-I/$LD_LIBRARY_PATH/include"
ENV CGO_LDFLAGS="-L/$LD_LIBRARY_PATH -lrocksdb -lstdc++ -lm -lz -lbz2 -lsnappy -llz4 -lzstd"
ENV EVMWRAP=/build/libevmwrap.so
RUN set -ex && \
# Update file limit
sed -i -e '$a* soft nofile 65536\n* hard nofile 65536' /etc/security/limits.conf && \
# Install apt based dependencies
apt-get -y update && \
apt-get -y upgrade && \
apt-get -y install cmake gcc-8 g++-8 gcc g++ git libgflags-dev zlib1g-dev libbz2-dev liblz4-dev libzstd-dev make wget && \
# Setup build directory
mkdir /build && \
# Install Go
cd /build && \
export GOPLATFORM=$(echo ${TARGETPLATFORM} | tr "/" "-") && echo ${GOPLATFORM} && \
wget https://dl.google.com/go/go${GOLANG_VERSION}.${GOPLATFORM}.tar.gz && \
tar zxvf go${GOLANG_VERSION}.${GOPLATFORM}.tar.gz -C /usr/local && \
mkdir -p $GOPATH/bin && \
# Patch Go for larger cgo stack size
wget https://github.com/smartbch/patch-cgo-for-golang/archive/refs/tags/v${PATCH_CGO_VERSION}.tar.gz && \
tar zxvf v${PATCH_CGO_VERSION}.tar.gz -C $GOROOT/src/runtime/cgo/ --strip-components=1 --wildcards "*.c" && \
go version && \
# Build libsnappy
cd /build && \
wget https://github.com/google/snappy/archive/refs/tags/${SNAPPY_VERSION}.tar.gz && \
mkdir -p snappy/build && tar zxvf ${SNAPPY_VERSION}.tar.gz -C snappy --strip-components=1 && \
cd snappy/build && cmake -DBUILD_SHARED_LIBS=On -DSNAPPY_BUILD_TESTS=0 -DCMAKE_BUILD_TYPE=Release ../ && make -j4 install && \
# Build rocksdb
cd /build && \
wget https://github.com/facebook/rocksdb/archive/refs/tags/v${ROCKSDB_VERSION}.tar.gz && \
mkdir rocksdb && tar zxvf v${ROCKSDB_VERSION}.tar.gz -C rocksdb --strip-components=1 && \
cd rocksdb && PORTABLE=1 DEBUG_LEVEL=0 make -j4 CC=gcc-8 CXX=g++-8 EXTRA_CXXFLAGS=-s shared_lib install-shared && \
# Remove build artifacts
rm -rf /build/* && \
# Build libevmwrap.so
cd /build && \
git clone -b ${MOEINGEVM_VERSION} --depth 1 https://github.com/smartbch/moeingevm && \
cd moeingevm/evmwrap && make -j4 && \
cp host_bridge/libevmwrap.so /build && \
rm -rf /build/moeingevm/ && \
# Build smartbchd
cd /build && \
git clone -b ${SMARTBCH_VERSION} --depth 1 https://github.com/smartbch/smartbch && \
cd smartbch && go build -tags ${SMARTBCH_BUILD_TAGS} github.com/smartbch/smartbch/cmd/smartbchd && \
cp smartbchd /build && \
rm -rf /build/smartbch/ && \
# Init chain
cd /root && \
/build/smartbchd init mynode --chain-id ${CHAIN_ID} && \
wget https://github.com/smartbch/artifacts/releases/download/${CONFIG_VERSION}/dot.smartbchd.tgz && \
tar zxvf dot.smartbchd.tgz -C .smartbchd/ --strip-components=1 && \
rm dot.smartbchd.tgz && \
# Remove compiler dependencies and clean up cache
rm -rf $GOROOT $GOPATH /root/.cache && \
apt-get -y remove cmake gcc-8 g++-8 gcc g++ git make wget && \
apt-get -y --purge autoremove && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# Go back to main workdir.
WORKDIR /build
VOLUME ["/root/.smartbchd"]
ENTRYPOINT ["./smartbchd"]
EXPOSE 8545 8546