Fullnode-mainnet image may encounter 'illegal instruction' incompatibility on a few machines. It is recommended to build the image yourself. Below is a guide on how to build the OKTC fullnode-mainnet image.
Building the build-env
- Preparing Dockerfile:
FROM golang:1.20-alpine
RUN apk add --no-cache \
make \
git \
libc-dev \
bash \
gcc \
linux-headers \
eudev-dev \
g++ \
snappy \
snappy-dev \
lz4 \
lz4-dev \
perl \
curl \
cmake \
ca-certificates \
build-base
RUN git clone https://github.com/facebook/rocksdb.git -b v6.27.3 && \
mv rocksdb /tmp/rocksdb && \
cd /tmp/rocksdb && \
sed -i 's/install -C /install -c /g' Makefile && \
make libsnappy.a && cp libsnappy.a /usr/lib && \
make liblz4.a && cp liblz4.a /usr/lib && \
make -j16 static_lib PREFIX=/usr LIBDIR=/usr/lib && \
make install-static PREFIX=/usr LIBDIR=/usr/lib && \
rm -rf /tmp/rocksdb
ADD https://github.com/CosmWasm/wasmvm/releases/download/v1.0.0/libwasmvm_muslc.x86_64.a /lib/libwasmvm_muslc.x86_64.a
RUN sha256sum /lib/libwasmvm_muslc.x86_64.a | grep f6282df732a13dec836cda1f399dd874b1e3163504dbd9607c6af915b2740479 && \
cp /lib/libwasmvm_muslc.x86_64.a /lib/libwasmvm_muslc.a
- Building the build-env
docker build -t build-env .
Building the fullnode-mainnet image
1.Preparing start.sh :
#!/bin/bash
if [ ! -d "/root/.exchaind/config" ]; then
exchaind init fullnode --chain-id exchain-66
wget https://raw.githubusercontent.com/okx/mainnet/main/genesis.json -O /root/.exchaind/config/genesis.json
fi
exchaind start \
--chain-id exchain-66 \
--rest.laddr tcp://0.0.0.0:8545 \
--db_backend rocksdb
- Preparing Dockerfile:
FROM build-env as builder
WORKDIR /root
ENV GO111MODULE=on \
GOPROXY=https://goproxy.io,direct
COPY exchain ./exchain
RUN cd exchain && \
make mainnet WITH_ROCKSDB=true LINK_STATICALLY=true
FROM golang:1.20-alpine
RUN apk add --no-cache bash
WORKDIR /root
COPY --from=builder $GOPATH/bin/exchaind $GOPATH/bin/exchaind
COPY --from=builder $GOPATH/bin/exchaincli $GOPATH/bin/exchaincli
COPY start.sh .
CMD ["sh", "-c", "/root/start.sh"]
EXPOSE 26656 26657 26660 6060 8545 8546
- Building
git https://github.com/okx/exchain.git
cd ./exchain
git checkout v1.7.1
cd ..
docker build -t fullnode-mainnet:v1.7.1 .
Starting the mainnet node
- Preparing the docker-compose file:
version: "2"
services:
okc:
container_name: okc
image: fullnode-mainnet:v1.7.1
environment:
- OKEXCHAIN_LOG_FILE=/root/logs/okexchaind.log
- OKEXCHAIN_LOG_STDOUT=false
- OKEXCHAIN_DB_BACKEND=rocksdb
- OKEXCHAIN_ELAPSED=DeliverTxs=2,Round=1,CommitRound=1,Produce=1
- OKEXCHAIN_LOG_LEVEL=main:info,iavl:info,*:error,tx-receiver:info
volumes:
- ./exchaind:/root/.exchaind
- ./logs:/root/logs
ports:
- "26656:26656"
- "26657:26657"
- "26660:26660"
- "8546:8546"
- "8545:8545"
- "6060:6060"
- Starting the node
docker-compose up -d