| @@ -0,0 +1,85 @@ | |||||
| <?xml version="1.0" encoding="UTF-8"?> | |||||
| <project xmlns="http://maven.apache.org/POM/4.0.0" | |||||
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |||||
| xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | |||||
| <parent> | |||||
| <artifactId>jdchain-root</artifactId> | |||||
| <groupId>com.jd.blockchain</groupId> | |||||
| <version>1.2.1.RELEASE</version> | |||||
| <relativePath>../../pom.xml</relativePath> | |||||
| </parent> | |||||
| <version>1.3.0</version> | |||||
| <modelVersion>4.0.0</modelVersion> | |||||
| <artifactId>docker-demo</artifactId> | |||||
| <build> | |||||
| <finalName>jdchain-demo</finalName> | |||||
| <plugins> | |||||
| <plugin> | |||||
| <artifactId>maven-resources-plugin</artifactId> | |||||
| <version>3.0.2</version> | |||||
| <executions> | |||||
| <execution> | |||||
| <id>copy-resources</id> | |||||
| <phase>validate</phase> | |||||
| <goals> | |||||
| <goal>copy-resources</goal> | |||||
| </goals> | |||||
| <configuration> | |||||
| <!-- 将资源文件拷贝到config目录下 --> | |||||
| <encoding>UTF-8</encoding> | |||||
| <outputDirectory>${project.basedir}/src/main/docker/zip</outputDirectory> | |||||
| <overwrite>false</overwrite> | |||||
| <resources> | |||||
| <resource> | |||||
| <directory>${project.basedir}/../deploy-peer/target/</directory> | |||||
| <filtering>false</filtering> | |||||
| <includes> | |||||
| <include>jdchain-peer-${project.version}.RELEASE.zip</include> | |||||
| </includes> | |||||
| </resource> | |||||
| <resource> | |||||
| <directory>${project.basedir}/../deploy-gateway/target/</directory> | |||||
| <filtering>false</filtering> | |||||
| <includes> | |||||
| <include>jdchain-gateway-${project.version}.RELEASE.zip</include> | |||||
| </includes> | |||||
| </resource> | |||||
| </resources> | |||||
| </configuration> | |||||
| </execution> | |||||
| </executions> | |||||
| </plugin> | |||||
| <!-- 使用Maven插件直接将应用打包为一个Docker镜像 --> | |||||
| <plugin> | |||||
| <groupId>com.spotify</groupId> | |||||
| <artifactId>docker-maven-plugin</artifactId> | |||||
| <version>1.2.2</version> | |||||
| <!--将插件绑定在某个phase执行--> | |||||
| <executions> | |||||
| <execution> | |||||
| <id>build-image</id> | |||||
| <!--将插件绑定在package这个phase上。也就是说,用户只需执行mvn package ,就会自动执行mvn docker:build--> | |||||
| <phase>package</phase> | |||||
| <goals> | |||||
| <goal>build</goal> | |||||
| </goals> | |||||
| </execution> | |||||
| </executions> | |||||
| <configuration> | |||||
| <imageName>jdchain-demo</imageName> | |||||
| <imageTags>${project.version}</imageTags> | |||||
| <!-- 指定 Dockerfile 路径--> | |||||
| <dockerDirectory>${project.basedir}/src/main/docker</dockerDirectory> | |||||
| </configuration> | |||||
| </plugin> | |||||
| </plugins> | |||||
| </build> | |||||
| </project> | |||||
| @@ -0,0 +1,41 @@ | |||||
| # jdchain-demo镜像使用说明 | |||||
| 本镜像主要为快速构建JDChain测试环境使用,内嵌固定的公私钥,不可用于生产正式环境。 | |||||
| JDChain在docker中的安装路径:/export/jdchain,网关对外端口为:8080。可通过docker-compose-all文件来修改端口。 | |||||
| demo环境中加载了部分测试数据,区块高度:22,交易总数:23,用户总数:6,数据账户总数:3,合约总数:2。 | |||||
| ## 如何生成镜像 | |||||
| 1. 需要预先在deploy-peer和deploy-gateway中生成zip安装包; | |||||
| 2. 本项目中执行:mvn clean package;会在docker环境中生成jdchain-peer镜像; | |||||
| 3. 生成镜像文件。执行resource中:zip.sh,可生成镜像的tar.gz压缩包; | |||||
| ## 镜像快速使用 | |||||
| 1.在已经安装docker工具的环境中,装入jdchain-demo镜像: | |||||
| ```` | |||||
| docker load -i jdchain-demo_1.3.0.tar.gz | |||||
| ```` | |||||
| 2.启动脚本 | |||||
| 每次执行启动脚本时,会删除原有的容器,然后重新构建全新的容器。 | |||||
| 所以每次执行之后,会清除原先链上新增的区块。 | |||||
| ```` | |||||
| sh start-net.sh | |||||
| ```` | |||||
| 3.卸载容器 | |||||
| 如果不再使用容器,在start-net.sh脚本所在路径下执行: | |||||
| ```` | |||||
| docker-compose -f docker-compose-all.yaml down | |||||
| ```` | |||||
| ## SDK连接网关参数 | |||||
| ```` | |||||
| ip=localhost | |||||
| port=8080 | |||||
| #默认公钥的内容(Base58编码数据); | |||||
| keys.default.pubkey=3snPdw7i7PisoLpqqtETdqzQeKVjQReP2Eid9wYK67q9z6trvByGZs | |||||
| #默认私钥的内容(加密的Base58编码数据);在 pk-path 和 pk 之间必须设置其一; | |||||
| keys.default.privkey=177gk2PbxhHeEdfAAqGfShJQyeV4XvGsJ9CvJFUbToBqwW1YJd5obicySE1St6SvPPaRrUP | |||||
| #默认私钥的解码密码; | |||||
| keys.default.privkey-password=8EjkXVSTxMFjCvNNsTo8RBMDEVQmk7gYkW4SCDuvdsBG | |||||
| ```` | |||||
| @@ -0,0 +1,35 @@ | |||||
| FROM centos:8.2.2004 | |||||
| # install tools | |||||
| RUN yum install wget -y \ | |||||
| && wget -O /etc/yum.repos.d/epel-7.repo http://mirrors.aliyun.com/repo/epel-7.repo \ | |||||
| && yum install java net-tools nc crontabs expect unzip -y \ | |||||
| && yum install langpacks-zh_CN.noarch -y \ | |||||
| && echo "LANG=zh_CN.utf8" >> /etc/locale.conf \ | |||||
| && source /etc/locale.conf \ | |||||
| && yum clean all | |||||
| WORKDIR /export/jdchain | |||||
| COPY zip/* /export/jdchain/ | |||||
| # env | |||||
| ENV RELEASE_DIR=/export/jdchain | |||||
| ENV RELEASE_VERSION=1.3.0 | |||||
| #ENV DATA_DIR=/shared | |||||
| ENV NAME=conf | |||||
| ENV SERVER_NAME_PEER=deploy-peer | |||||
| ENV SERVER_NAME_GW=deploy-gateway | |||||
| COPY script/* /export/jdchain/ | |||||
| RUN chmod +x /export/jdchain/*.sh | |||||
| # ports | |||||
| EXPOSE 8080 | |||||
| #EXPOSE 16000 | |||||
| #EXPOSE 16010 | |||||
| #EXPOSE 16020 | |||||
| #EXPOSE 16030 | |||||
| #ENTRYPOINT ["/bin/sh","-c","/export/jdchain/start.sh"] | |||||
| ENTRYPOINT sh /export/jdchain/start.sh | |||||
| @@ -0,0 +1,4 @@ | |||||
| #!/bin/bash | |||||
| ps -ef|grep 'jdchain'|grep -v grep|cut -c 9-15|xargs kill -9 | |||||
| @@ -0,0 +1,28 @@ | |||||
| #!/bin/bash | |||||
| cd $RELEASE_DIR | |||||
| # invoke it once again; | |||||
| #gw_pid_file="./gw/bin/PID.log" | |||||
| #if [ ! -f gw_pid_file ] ; then | |||||
| # echo "get the PID.log, only to start the peer and gateway." | |||||
| unzip -o conf.zip | |||||
| for i in `seq 0 3` | |||||
| do | |||||
| unzip -n -d ./peer$i jdchain-peer-$RELEASE_VERSION.RELEASE.zip | |||||
| chmod +x ./peer$i/bin/* | |||||
| done | |||||
| unzip -n -d ./gw jdchain-gateway-$RELEASE_VERSION.RELEASE.zip | |||||
| chmod +x ./gw/bin/* | |||||
| #fi | |||||
| sh ./peer0/bin/peer-startup.sh | |||||
| sh ./peer1/bin/peer-startup.sh | |||||
| sh ./peer2/bin/peer-startup.sh | |||||
| sh ./peer3/bin/peer-startup.sh | |||||
| sleep 30 | |||||
| sh ./gw/bin/startup.sh | |||||
| tail -f /dev/null | |||||
| @@ -0,0 +1,36 @@ | |||||
| version: '2' | |||||
| services: | |||||
| demo: | |||||
| image: "jdchain-demo:1.3.0" | |||||
| container_name: jdchain-demo | |||||
| networks: | |||||
| jdchain_default: | |||||
| aliases: | |||||
| - demo | |||||
| hostname: demo | |||||
| restart: always | |||||
| ports: | |||||
| - "11010:11010" | |||||
| - "7080:7080" | |||||
| - "10080:10080" | |||||
| - "10081:10081" | |||||
| - "11011:11011" | |||||
| - "7081:7081" | |||||
| - "10082:10082" | |||||
| - "10083:10083" | |||||
| - "11012:11012" | |||||
| - "7082:7082" | |||||
| - "10084:10084" | |||||
| - "10085:10085" | |||||
| - "11013:11013" | |||||
| - "7083:7083" | |||||
| - "10086:10086" | |||||
| - "10087:10087" | |||||
| - "8080:8080" | |||||
| # volumes: | |||||
| # - "./logs:/export/jdchain/peer0/logs" | |||||
| networks: | |||||
| jdchain_default: | |||||
| driver: bridge | |||||
| @@ -0,0 +1,5 @@ | |||||
| #!/bin/bash | |||||
| echo "停止network" | |||||
| docker-compose -f docker-compose-all.yaml down | |||||
| echo "启动jdchain" | |||||
| docker-compose -f docker-compose-all.yaml up -d | |||||
| @@ -0,0 +1,9 @@ | |||||
| #/bin/bash | |||||
| # all in one; | |||||
| allIn1_file="./jdchain-demo_1.3.0.tar.gz" | |||||
| if [ -f $allIn1_file ] ; then | |||||
| rm -rf $allIn1_file | |||||
| fi | |||||
| docker save jdchain-demo:1.3.0 -o jdchain-demo_1.3.0.tar | |||||
| gzip jdchain-demo_1.3.0.tar | |||||
| @@ -20,6 +20,7 @@ | |||||
| <module>../core</module> | <module>../core</module> | ||||
| <module>deploy-gateway</module> | <module>deploy-gateway</module> | ||||
| <module>deploy-peer</module> | <module>deploy-peer</module> | ||||
| <module>docker-demo</module> | |||||
| </modules> | </modules> | ||||
| </project> | </project> | ||||