forked from smartbch/smartbch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile.mainnet
85 lines (65 loc) · 2.78 KB
/
Dockerfile.mainnet
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
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"
# Update file limit
RUN sed -i -e '$a* soft nofile 65536\n* hard nofile 65536' /etc/security/limits.conf
# Install apt based dependencies
ENV DEBIAN_FRONTEND="noninteractive"
RUN apt-get -y update && apt-get -y upgrade
RUN apt-get -y install cmake gcc-8 g++-8 gcc g++ git libgflags-dev zlib1g-dev libbz2-dev liblz4-dev libzstd-dev make vim wget
# Setup build directory
RUN mkdir /build
WORKDIR /build
# Install Go
RUN wget https://dl.google.com/go/go${GOLANG_VERSION}.linux-amd64.tar.gz
RUN tar zxvf go${GOLANG_VERSION}.linux-amd64.tar.gz
RUN mv go /usr/local
RUN mkdir -p /go/bin
ENV GOROOT=/usr/local/go
ENV GOPATH=/go
ENV PATH=$GOPATH/bin:$GOROOT/bin:$PATH
# Patch Go for larger cgo stack size
RUN wget https://github.com/smartbch/patch-cgo-for-golang/archive/refs/tags/v${PATCH_CGO_VERSION}.tar.gz
RUN tar zxvf v${PATCH_CGO_VERSION}.tar.gz
RUN rm v${PATCH_CGO_VERSION}.tar.gz
RUN cd patch-cgo-for-golang-${PATCH_CGO_VERSION} && cp *.c $GOROOT/src/runtime/cgo/
# Build libsnappy
RUN wget https://github.com/google/snappy/archive/refs/tags/${SNAPPY_VERSION}.tar.gz
RUN tar zxvf ${SNAPPY_VERSION}.tar.gz
RUN cd snappy-${SNAPPY_VERSION} && mkdir build && cd build && cmake -DBUILD_SHARED_LIBS=On ../ && make && make install
# Build rocksdb
RUN wget https://github.com/facebook/rocksdb/archive/refs/tags/v${ROCKSDB_VERSION}.tar.gz
RUN tar zxvf v${ROCKSDB_VERSION}.tar.gz
RUN cd rocksdb-${ROCKSDB_VERSION} && make CC=gcc-8 CXX=g++-8 shared_lib
ENV ROCKSDB_PATH="/build/rocksdb-${ROCKSDB_VERSION}"
ENV CGO_CFLAGS="-I/$ROCKSDB_PATH/include"
ENV CGO_LDFLAGS="-L/$ROCKSDB_PATH -lrocksdb -lstdc++ -lm -lz -lbz2 -lsnappy -llz4 -lzstd"
ENV LD_LIBRARY_PATH=$ROCKSDB_PATH:/usr/local/lib
# Create smartbch directory
RUN mkdir /smart_bch
WORKDIR /smart_bch
# Build libevmwrap.so
RUN git clone -b ${MOEINGEVM_VERSION} --depth 1 https://github.com/smartbch/moeingevm
RUN cd moeingevm/evmwrap && make
ENV EVMWRAP=/smart_bch/moeingevm/evmwrap/host_bridge/libevmwrap.so
# Build smartbchd
RUN git clone -b ${SMARTBCH_VERSION} --depth 1 https://github.com/smartbch/smartbch
RUN cd smartbch && go build -tags cppbtree github.com/smartbch/smartbch/cmd/smartbchd
# Setup smartbchd
RUN cp /smart_bch/smartbch/smartbchd /build/smartbchd
WORKDIR /root
RUN /build/smartbchd init mynode --chain-id 0x2710
RUN wget https://github.com/smartbch/artifacts/releases/download/${CONFIG_VERSION}/dot.smartbchd.tgz
RUN tar zxvf dot.smartbchd.tgz
RUN cp -rf dot.smartbchd/* .smartbchd/
# Go back to main workdir.
WORKDIR /build
VOLUME ["/root/.smartbchd"]
ENTRYPOINT ["./smartbchd"]
EXPOSE 8545 8546