forked from bcosorg/bcos
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request bcosorg#27 from bxq2011hust/master
add dockerfile
- Loading branch information
Showing
19 changed files
with
1,230 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
FROM alpine:3.6 | ||
|
||
LABEL maintainer hi@bcos.org.cn | ||
|
||
RUN echo -e "http://mirrors.aliyun.com/alpine/edge/testing\nhttp://mirrors.aliyun.com/alpine/v3.6/main\nhttp://mirrors.aliyun.com/alpine/v3.6/community\n" > /etc/apk/repositories | ||
RUN apk update && apk add --no-cache \ | ||
libstdc++ \ | ||
# boost-dev \ | ||
boost-system \ | ||
boost-filesystem \ | ||
boost-random \ | ||
boost-regex \ | ||
boost-thread \ | ||
gmp \ | ||
libcurl libmicrohttpd libcrypto1.0 leveldb | ||
|
||
RUN apk add --no-cache --virtual .build-deps \ | ||
unzip \ | ||
git \ | ||
cmake \ | ||
g++ \ | ||
make \ | ||
curl-dev boost-dev libmicrohttpd-dev openssl-dev leveldb-dev \ | ||
&& sed -i -E -e 's/include <sys\/poll.h>/include <poll.h>/' /usr/include/boost/asio/detail/socket_types.hpp \ | ||
&& git clone https://github.com/bcosorg/bcos.git \ | ||
&& cd bcos && mkdir build && cd build \ | ||
# && sed -i 's/boost_thread/boost_thread-mt/g' ../libdevcore/CMakeLists.txt \ | ||
&& cmake -DEVMJIT=OFF -DTESTS=OFF -DTOOLS=OFF -DMINIUPNPC=OFF .. \ | ||
&& make \ | ||
&& make install \ | ||
&& mkdir /nodedata && cd ../docker && cp nodeConfig/node-0/* /nodedata \ | ||
&& cd / && rm -rf bcos \ | ||
&& apk del .build-deps \ | ||
&& rm /var/cache/apk/* -f | ||
|
||
EXPOSE 35500 53300 | ||
|
||
CMD ["/usr/local/bin/bcoseth","--genesis","/nodedata/genesis.json", "--config","/nodedata/config.json"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
FROM centos:7 | ||
|
||
LABEL maintainer hi@bcos.org.cn | ||
|
||
# aliyun | ||
# RUN curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo \ | ||
# && yum clean all && yum makecache fast && yum -y update | ||
|
||
RUN yum -y -q install epel-release && yum -q -y install \ | ||
git \ | ||
cmake3 \ | ||
make \ | ||
gcc-c++ \ | ||
boost-devel \ | ||
leveldb-devel \ | ||
curl-devel \ | ||
libmicrohttpd-devel \ | ||
gmp-devel \ | ||
openssl-devel \ | ||
&& git clone https://github.com/bcosorg/bcos.git \ | ||
&& cd bcos && mkdir build && cd build \ | ||
&& cmake3 -DEVMJIT=OFF -DTESTS=OFF -DTOOLS=Off -DMINIUPNPC=OFF .. \ | ||
&& make \ | ||
&& make install \ | ||
&& mkdir /nodedata && cd ../docker && cp nodeConfig/node-0/* /nodedata \ | ||
&& cd / && rm -rf bcos \ | ||
&& yum -y remove git cmake3 make gcc-c++ unzip \ | ||
&& yum clean all | ||
|
||
EXPOSE 35500 53300 | ||
|
||
CMD ["/usr/local/bin/bcoseth","--genesis","/nodedata/genesis.json", "--config","/nodedata/config.json"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
FROM ubuntu:16.04 | ||
|
||
LABEL maintainer hi@bcos.org.cn | ||
|
||
## tencentyun | ||
# RUN echo "deb http://mirrors.tencentyun.com/ubuntu xenial main restricted universe multiverse \n \ | ||
# deb http://mirrors.tencentyun.com/ubuntu xenial-updates main restricted universe multiverse \n \ | ||
# deb http://mirrors.tencentyun.com/ubuntu-security xenial-security main restricted universe multiverse \n \ | ||
# deb-src http://mirrors.tencentyun.com/ubuntu xenial main restricted universe multiverse \n \ | ||
# deb-src http://mirrors.tencentyun.com/ubuntu xenial-updates main restricted universe multiverse" > /etc/apt/sources.list | ||
|
||
## aliyun | ||
RUN echo "deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted \n \ | ||
deb-src http://archive.ubuntu.com/ubuntu xenial main restricted #Added by software-properties \n \ | ||
deb-src http://mirrors.aliyun.com/ubuntu/ xenial main restricted multiverse universe #Added by software-properties \n \ | ||
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted \n \ | ||
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted multiverse universe #Added by software-properties \n \ | ||
deb http://mirrors.aliyun.com/ubuntu/ xenial universe \n \ | ||
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates universe \n \ | ||
deb http://mirrors.aliyun.com/ubuntu/ xenial multiverse \n \ | ||
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates multiverse \n \ | ||
deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse \n \ | ||
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse #Added by software-properties \n \ | ||
deb http://archive.canonical.com/ubuntu xenial partner \n \ | ||
deb-src http://archive.canonical.com/ubuntu xenial partner \n \ | ||
deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted \n \ | ||
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted multiverse universe #Added by software-properties \n \ | ||
deb http://mirrors.aliyun.com/ubuntu/ xenial-security universe \n \ | ||
deb http://mirrors.aliyun.com/ubuntu/ xenial-security multiverse" > /etc/apt/sources.list | ||
|
||
RUN apt-get -q update && apt-get install -qy --no-install-recommends \ | ||
build-essential \ | ||
cmake \ | ||
git \ | ||
libboost-all-dev \ | ||
libleveldb-dev \ | ||
libcurl4-openssl-dev \ | ||
libgmp-dev \ | ||
libmicrohttpd-dev \ | ||
libminiupnpc-dev \ | ||
libssl-dev \ | ||
ca-certificates \ | ||
&& git clone https://github.com/bcosorg/bcos.git \ | ||
&& cd bcos && mkdir build && cd build \ | ||
&& cmake -DEVMJIT=OFF -DTESTS=OFF -DTOOLS=Off -DMINIUPNPC=OFF .. \ | ||
&& make \ | ||
&& make install \ | ||
&& mkdir /nodedata && cd ../docker && cp nodeConfig/node-0/* /nodedata \ | ||
&& cd / && rm -rf bcos \ | ||
# clean | ||
&& apt-get purge git cmake build-essential -y \ | ||
&& apt-get autoremove -y \ | ||
&& apt-get clean \ | ||
&& rm /tmp/* -rf \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
EXPOSE 35500 53300 | ||
|
||
CMD ["/usr/local/bin/bcoseth","--genesis","/nodedata/genesis.json", "--config","/nodedata/config.json"] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
# BCOS-Docker使用 | ||
<!-- TOC --> | ||
|
||
- [BCOS-Docker使用](#bcos-docker使用) | ||
- [1. 单节点网络](#1-单节点网络) | ||
- [1.1 生成配置文件与启动容器](#11-生成配置文件与启动容器) | ||
- [1.2 查看工作状态](#12-查看工作状态) | ||
- [2. 多节点网络](#2-多节点网络) | ||
- [2.1 配置系统合约](#21-配置系统合约) | ||
- [2.2 生成新节点配置文件](#22-生成新节点配置文件) | ||
- [2.3 新加节点入网](#23-新加节点入网) | ||
- [2.4 查看网络状态](#24-查看网络状态) | ||
|
||
<!-- /TOC --> | ||
|
||
## 1. 单节点网络 | ||
|
||
我们提供Dockerfile文件和`Docker Hub`上预构建的镜像([地址][bcos-docker]),下面示例中当`bcosorg/bcos`镜像不存在时,Docker会自动去仓库拉取,考虑到网络问题,建议配置国内的Docker镜像加速服务。Docker安装参照[官方文档][Docker-Install]。 | ||
|
||
### 1.1 生成配置文件与启动容器 | ||
|
||
```bash | ||
$ cd bcos/docker && chmod +x scripts/genConfig.sh && chmod +x scripts/start_bcos_docker.sh | ||
# 产生配置文件位于文件夹node-0 | ||
$ ./scripts/genConfig.sh | ||
# 启动容器 | ||
$ ./scripts/start_bcos_docker.sh $PWD/node-0 | ||
``` | ||
|
||
### 1.2 查看工作状态 | ||
|
||
```bash | ||
# 连接到容器 | ||
$ docker exec -it $(docker ps -a | grep bcos-node-0 | awk 'NR==1{print $1}') sh | ||
# 查看日志,blk不断增长说明单节点网络已正常工作 | ||
|
||
$ tail -f /nodedata/logs/info* | grep "Report" | ||
INFO |2017-07-05 07:37:15|^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Report: blk=314,hash=881cff6fe6f7f8863ee3f9ba6cffa69614337d15523f6a4332503b4b6879b6fe,idx=0, Next: blk=315 | ||
INFO |2017-07-05 07:37:16|^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Report: blk=315,hash=2aede959eabe75405ef2a7b718111e9bf32aa047c3b1d5b6d173a25c228fea96,idx=0, Next: blk=316 | ||
``` | ||
|
||
********************************************************* | ||
|
||
## 2. 多节点网络 | ||
|
||
按照[步骤1](#1-单节点网络)**启动单节点网络**,然后按下述步骤操作 | ||
|
||
### 2.1 配置系统合约 | ||
|
||
```bash | ||
$ cd bcos/systemcontractv2 | ||
$ cnpm install | ||
# 修改config.js中proxy端口为35500 | ||
$ sed -i 's/127.0.0.1:8545/127.0.0.1:35500/' config.js | ||
$ babel-node deploy.js | ||
# 将输出中,SystemProxy合约地址记下来 | ||
SystemProxy合约地址 0xff27dc5cc5144c626b9fdc26b2f292d9df062470 | ||
|
||
# 修改docker/node-0/config.json中systemproxyaddress为上述输出 | ||
$ sed -i 's/"systemproxyaddress":"0x0"/"systemproxyaddress":"0xff27dc5cc5144c626b9fdc26b2f292d9df062470"/' ../docker/node-0/config.json | ||
# 重启node-0 | ||
$ docker restart $(docker ps -a | grep bcos-node-0 | awk 'NR==1{print$1}') | ||
|
||
# 创世节点信息写入合约 | ||
$ babel-node tool.js NodeAction registerNode ../docker/node-0/node.json | ||
``` | ||
|
||
### 2.2 生成新节点配置文件 | ||
|
||
执行下面命令生成`node-1`节点配置文件。 | ||
|
||
```bash | ||
$ cd bcos/docker | ||
# genConfig.sh的参数分别是除创世节点外的组网节点数和创世节点配置文件路径 | ||
$ ./scripts/genConfig.sh 1 node-0 | ||
``` | ||
|
||
### 2.3 新加节点入网 | ||
|
||
```bash | ||
$ cd bcos/systemcontractv2 | ||
# 新加节点信息写入合约 | ||
$ babel-node tool.js NodeAction registerNode ../docker/node-1/node.json | ||
# 启动新加入节点,参数为新节点配置文件完整路径 | ||
$ ../docker/scripts/start_bcos_docker.sh $PWD/node-1 | ||
# 要加入更多节点只需要重复步骤2.2-2.3,启动新节点时参数改为新节点配置文件路径即可 | ||
``` | ||
|
||
### 2.4 查看网络状态 | ||
|
||
```bash | ||
# 查看工作状态 | ||
# 块高增长说明网络工作正常 | ||
$ cd bcos/systemcontractv2 | ||
$ babel-node monitor.js | ||
RPC=http://127.0.0.1:35500 | ||
Ouputpath=./output/ | ||
已连接节点数:1 | ||
...........Node 0......... | ||
NodeId:ae8f25ee89f00db93283f7f05be1441780581716e7890b60de87ae49d4bf5e4b4436f496780c10dbed8f85d819a3e2333ef7dcd06bc114ea98ef827cf074d8f3 | ||
Host:172.17.0.1:53301 | ||
|
||
当前块高377 | ||
-------------------------------------------------------------- | ||
已连接节点数:1 | ||
...........Node 0......... | ||
NodeId:ae8f25ee89f00db93283f7f05be1441780581716e7890b60de87ae49d4bf5e4b4436f496780c10dbed8f85d819a3e2333ef7dcd06bc114ea98ef827cf074d8f3 | ||
Host:172.17.0.1:53301 | ||
|
||
当前块高378 | ||
``` | ||
|
||
********************************************************* | ||
[Docker-Install]:https://docs.docker.com/engine/installation/ | ||
[official mirror]:https://docs.docker.com/registry/recipes/mirror/#configure-the-docker-daemon | ||
[docker-accelerate]:https://yq.aliyun.com/articles/29941?spm=5176.100239.blogcont7695.18.jyYdbj | ||
[bcos-manual]:https://github.com/bcosorg/bcos/blob/master/doc/manual/manual.md | ||
[bcos-docker]:https://hub.docker.com/r/bcosorg/bcos/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
{ | ||
"sealEngine": "PBFT", | ||
"systemproxyaddress":"0xff27dc5cc5144c626b9fdc26b2f292d9df062470", | ||
"listenip":"0.0.0.0", | ||
"rpcport":"35500", | ||
"p2pport":"53300", | ||
"wallet":"/nodedata/keys.info", | ||
"keystoredir":"/nodedata/keystore/", | ||
"datadir":"/nodedata/", | ||
"vm":"interpreter", | ||
"networkid":"123456", | ||
"logverbosity":"4", | ||
"coverlog":"OFF", | ||
"eventlog":"ON", | ||
"logconf":"/nodedata/log.conf", | ||
"params": { | ||
"accountStartNonce": "0x0", | ||
"maximumExtraDataSize": "0x0", | ||
"tieBreakingGas": false, | ||
"blockReward": "0x0", | ||
"networkID" : "0x0" | ||
}, | ||
"NodeextraInfo":[ | ||
{ | ||
"Nodeid":"6b58b7ad8602c247a52e07bf17180e6a0a6e3c5a8809af5f51e84bec2c3894ad5a311245086e895d832c0756440b7f341d3e9fc7bbbd4e32299634200b11ffc6", | ||
"Nodedesc": "node0", | ||
"Agencyinfo": "node0", | ||
"Peerip": "172.17.0.1", | ||
"Identitytype": 1, | ||
"Port":53300, | ||
"Idx":0 | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"nonce": "0x0", | ||
"difficulty": "0x0", | ||
"mixhash": "0x0", | ||
"coinbase": "0x0", | ||
"timestamp": "0x0", | ||
"parentHash": "0x0", | ||
"extraData": "0x0", | ||
"gasLimit": "0x13880000000000", | ||
"god":"0x4d23de3297034cdd4a58db35f659a9b61fc7577b", | ||
"alloc": {}, | ||
"initMinerNodes":["6b58b7ad8602c247a52e07bf17180e6a0a6e3c5a8809af5f51e84bec2c3894ad5a311245086e895d832c0756440b7f341d3e9fc7bbbd4e32299634200b11ffc6"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
* GLOBAL: | ||
ENABLED = true | ||
TO_FILE = true | ||
TO_STANDARD_OUTPUT = false | ||
FORMAT = "%level|%datetime{%Y-%M-%d %H:%m:%s}|%msg" | ||
FILENAME = "/nodedata/logs/log_%datetime{%Y%M%d%H}.log" | ||
MILLISECONDS_WIDTH = 3 | ||
PERFORMANCE_TRACKING = false | ||
MAX_LOG_FILE_SIZE = 209715200 ## 200MB - Comment starts with two hashes (##) | ||
LOG_FLUSH_THRESHOLD = 100 ## Flush after every 100 logs | ||
* TRACE: | ||
ENABLED = false | ||
* DEBUG: | ||
ENABLED = false | ||
* FATAL: | ||
ENABLED = false | ||
* ERROR: | ||
FILENAME = "/nodedata/logs/error_log_%datetime{%Y%M%d%H}.log" | ||
* WARNING: | ||
ENABLED = false | ||
* INFO: | ||
FILENAME = "/nodedata/logs/info_log_%datetime{%Y%M%d%H}.log" | ||
* VERBOSE: | ||
ENABLED = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
���ցHbL� | ||
w�[������٢ؑYc�!Ѡ-� |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
6b58b7ad8602c247a52e07bf17180e6a0a6e3c5a8809af5f51e84bec2c3894ad5a311245086e895d832c0756440b7f341d3e9fc7bbbd4e32299634200b11ffc6 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"id":"6b58b7ad8602c247a52e07bf17180e6a0a6e3c5a8809af5f51e84bec2c3894ad5a311245086e895d832c0756440b7f341d3e9fc7bbbd4e32299634200b11ffc6", | ||
"ip":"172.17.0.1", | ||
"port":53300, | ||
"category":1, | ||
"desc":"node0", | ||
"CAhash":"", | ||
"agencyinfo":"node0", | ||
"idx":0 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
{ | ||
"sealEngine": "PBFT", | ||
"systemproxyaddress":"0xff27dc5cc5144c626b9fdc26b2f292d9df062470", | ||
"listenip":"0.0.0.0", | ||
"rpcport":"35501", | ||
"p2pport":"53301", | ||
"wallet":"/nodedata/keys.info", | ||
"keystoredir":"/nodedata/keystore/", | ||
"datadir":"/nodedata/", | ||
"vm":"interpreter", | ||
"networkid":"123456", | ||
"logverbosity":"4", | ||
"coverlog":"OFF", | ||
"eventlog":"ON", | ||
"logconf":"/nodedata/log.conf", | ||
"params": { | ||
"accountStartNonce": "0x0", | ||
"maximumExtraDataSize": "0x0", | ||
"tieBreakingGas": false, | ||
"blockReward": "0x0", | ||
"networkID" : "0x0" | ||
}, | ||
"NodeextraInfo":[ | ||
{ | ||
"Nodeid":"6b58b7ad8602c247a52e07bf17180e6a0a6e3c5a8809af5f51e84bec2c3894ad5a311245086e895d832c0756440b7f341d3e9fc7bbbd4e32299634200b11ffc6", | ||
"Nodedesc": "node0", | ||
"Agencyinfo": "node0", | ||
"Peerip": "172.17.0.1", | ||
"Identitytype": 1, | ||
"Port":53300, | ||
"Idx":0 | ||
}, | ||
{ | ||
"Nodeid":"ae8f25ee89f00db93283f7f05be1441780581716e7890b60de87ae49d4bf5e4b4436f496780c10dbed8f85d819a3e2333ef7dcd06bc114ea98ef827cf074d8f3", | ||
"Nodedesc": "node1", | ||
"Agencyinfo": "node1", | ||
"Peerip": "172.17.0.1", | ||
"Identitytype": 1, | ||
"Port":53301, | ||
"Idx":1 | ||
} | ||
] | ||
} |
Oops, something went wrong.