栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

国产统信arm64部署fabric2.2

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

国产统信arm64部署fabric2.2

1. 构建golang环境
## 直接下载包 安装即可
wget https://studygolang.com/dl/golang/go1.16.10.linux-arm64.tar.gz
## 具体安装不陈述了
2. 构建fabric-ca
make fabric-ca-client

make fabric-ca-server
3. 构建fabric
make configtxgen
make configtxlator
make orderer
make peer
4. 构建chaincode
自己的链码且非docker本地部署,需要在环境编译使用
5. 部署区块网络 5.1 非docker
## 把以上编译二进制文件拷贝bin中

## 其他注意外部部署配置路径就行
安装教程部署即可
5.2 docker 5.2.1 适配docker
 ## 可以找到包进行安装
wget https://download.docker.com/linux/debian/dists/stretch/pool/stable/arm64/docker-ce_18.06.3~ce~3-0~debian_arm64.deb
5.2.2 适配docker-compose
##1. 安装python3.5以上版本
## 2. pip升级
pip install --upgrade pip
##2. 安装docker-compose
pip install docker-compose --ignore-installed requests
5.2.3 制作基础镜像
## 如果没有debootstrap
## 有网
sudo apt install debootstrap
## 无网
http://ftp.cn.debian.org/debian/pool/main/d/debootstrap/debootstrap_1.0.89_all.deb
去地址下载安装包 去安装

sudo debootstrap --arch=arm64 --no-check-gpg  stretch rootfs http://mirrors.ustc.edu.cn/debian

sudo tar -C rootfs -c . | docker import - rootfs
5.2.4 制作golang镜像
Dockerfile
    #
    #
    FROM rootfs:latest
    
    #RUN apk add --no-cache 
    #		ca-certificates
    
    # set up nsswitch.conf for Go's "netgo" implementation
    # - https://github.com/golang/go/blob/go1.9.1/src/net/conf.go#L194-L275
    # - docker run --rm debian:stretch grep '^hosts:' /etc/nsswitch.conf
    #RUN [ ! -e /etc/nsswitch.conf ] && echo 'hosts: files dns' > /etc/nsswitch.conf
    
    ENV PATH /usr/local/go/bin:$PATH
    
    ENV GOLANG_VERSION 1.16.10
    
    RUN set -eux
    RUN apt install -y bash 
    RUN apt install make --allow-unauthenticated -y
    RUN apt install gcc --allow-unauthenticated -y
    RUN apt install g++ --allow-unauthenticated -y
    RUN apt install gnupg --allow-unauthenticated -y
    RUN apt install golang --allow-unauthenticated -y
    RUN apt install musl-dev --allow-unauthenticated -y
    RUN apt install openssl --allow-unauthenticated -y
    
    RUN export 
    # set GOROOT_BOOTSTRAP such that we can actually build Go
    	GOROOT_BOOTSTRAP="$(go env GOROOT)" 
    # ... and set "cross-building" related vars to the installed system's values so that we create a build targeting the proper arch
    # (for example, if our build host is GOARCH=amd64, but our build env/image is GOARCH=386, our build needs GOARCH=386)
    	GOOS="$(go env GOOS)" 
    	GOARCH="$(go env GOARCH)" 
    	GOHOSTOS="$(go env GOHOSTOS)" 
    	GOHOSTARCH="$(go env GOHOSTARCH)"
    	
    # also explicitly set GO386 and GOARM if appropriate
    # https://github.com/docker-library/golang/issues/184
    #RUN apkArch="$(apk --print-arch)"; 
    #	case "$apkArch" in 
    #		armhf) export GOARM='6' ;; 
    #		armv7) export GOARM='7' ;; 
    #		x86) export GO386='387' ;; 
    #	esac
    	
    # https://github.com/golang/go/issues/38536#issuecomment-616897960
    COPY go1.16.10.src.tar.gz /
    # https://github.com/golang/go/issues/14739#issuecomment-324767697
    RUN export GNUPGHOME="$(mktemp -d)"; 
    	tar -C /usr/local -xzf go1.16.10.src.tar.gz; 
    	rm go1.16.10.src.tar.gz; 
    	
    	goEnv="$(go env | sed -rn -e '/^GO(OS|ARCH|ARM|386)=/s//export /p')"; 
    	eval "$goEnv"; 
    	[ -n "$GOOS" ]; 
    	[ -n "$GOARCH" ]; 
    	( 
    		cd /usr/local/go/src; 
    		./make.bash; 
    	); 
    	
    	#pk del --no-network .build-deps; 
    	
    # pre-compile the standard library, just like the official binary release tarballs do
    	go install std; 
    # go install: -race is only supported on linux/amd64, linux/ppc64le, linux/arm64, freebsd/amd64, netbsd/amd64, darwin/amd64 and windows/amd64
    #	go install -race std; 
    	
    # remove a few intermediate / bootstrapping files the official binary release tarballs do not contain
    	rm -rf 
    		/usr/local/go/pkgapi 
    		/usr/local/go/pkg/tool/*/go_bootstrap 
    		/usr/local/go/src/cmd/dist/dist 
    	; 
    	
    	go version
    
    ENV GOPATH /go
    ENV PATH $GOPATH/bin:$PATH
    RUN mkdir -p "$GOPATH/src" "$GOPATH/bin" && chmod -R 777 "$GOPATH"
    WORKDIR $GOPATH
    ## 下载golang源码 放到和Dockerfile同一级目录
    wget https://studygolang.com/dl/golang/go1.16.10.src.tar.gz

    docker build -t golang:latest .
5.2.5 制作fabric-ca镜像
  image/fabric/Dockerfile如下
    #
    # Copyright IBM Corp. All Rights Reserved.
    #
    # SPDX-License-Identifier: Apache-2.0
    #
    ARG GO_VER
    ARG ALPINE_VER
    
    FROM golang:latest as builder
    ARG GO_LDFLAGS
    ARG GO_TAGS
    
    RUN apt install gcc --allow-unauthenticated -y
    RUN apt install binutils-gold --allow-unauthenticated -y
    RUN apt install git --allow-unauthenticated -y
    RUN apt install musl-dev --allow-unauthenticated -y
    
    ADD . /build/fabric-ca
    WORKDIR /build/fabric-ca
    RUN go install -tags "${GO_TAGS}" -ldflags "${GO_LDFLAGS}" 
            github.com/hyperledger/fabric-ca/cmd/fabric-ca-server 
            && go install -tags "${GO_TAGS}" -ldflags "${GO_LDFLAGS}" 
            github.com/hyperledger/fabric-ca/cmd/fabric-ca-client
    
    
    FROM rootfs:latest
    #RUN apk add --no-cache 
    #       tzdata;
    ENV FABRIC_CA_HOME /etc/hyperledger/fabric-ca-server
    COPY --from=builder /go/bin /usr/local/bin
    EXPOSE 7054
    CMD fabric-ca-server start -b admin:adminpw
make docker
5.2.6 制作fabric
    ## baseos  /images/baseos/Dockerfile
    # Copyright IBM Corp. All Rights Reserved.
    #
    # SPDX-License-Identifier: Apache-2.0
    
    ARG GO_VER
    ARG ALPINE_VER
    
    FROM rootfs:latest as base
    RUN apt install tzdata --allow-unauthenticated -y
    #RUN addgroup -g 500 chaincode && adduser -u 500 -D -h /home/chaincode -G chaincode chaincode
    #USER chaincode
  ccenv images/ccenv/Dockerfile
    # Copyright IBM Corp. All Rights Reserved.
    #
    # SPDX-License-Identifier: Apache-2.0
    
    ARG GO_VER
    ARG ALPINE_VER
    FROM golang:latest
    RUN apt install g++ --allow-unauthenticated -y
    RUN apt install gcc --allow-unauthenticated -y
    RUN apt install git --allow-unauthenticated -y
    RUN apt install musl-dev --allow-unauthenticated -y
    
    RUN mkdir -p /chaincode/output /chaincode/input
    #RUN addgroup -g 500 chaincode && adduser -u 500 -D -h /home/chaincode -G chaincode chaincode
    #RUN chown -R chaincode:chaincode /chaincode
    #USER chaincode
  orderer images/orderer/Dockerfile
    # Copyright IBM Corp. All Rights Reserved.
    #
    # SPDX-License-Identifier: Apache-2.0
    
    ARG GO_VER
    ARG ALPINE_VER
    FROM rootfs:latest as base
    #RUN apk add --no-cache tzdata
    RUN apt install tzdata --allow-unauthenticated -y
    # set up nsswitch.conf for Go's "netgo" implementation
    # - https://github.com/golang/go/blob/go1.9.1/src/net/conf.go#L194-L275
    # - docker run --rm debian:stretch grep '^hosts:' /etc/nsswitch.conf
    #RUN [ ! -e /etc/nsswitch.conf ] && echo 'hosts: files dns' > /etc/nsswitch.conf
    
    FROM golang:latest as golang
    RUN apt install gcc --allow-unauthenticated -y
    RUN apt install g++ --allow-unauthenticated -y
    RUN apt install musl-dev --allow-unauthenticated -y
    RUN apt install git --allow-unauthenticated -y
    RUN apt install bash --allow-unauthenticated -y
    RUN apt install make --allow-unauthenticated -y
    
    ADD . $GOPATH/src/github.com/hyperledger/fabric
    WORKDIR $GOPATH/src/github.com/hyperledger/fabric
    
    FROM golang as orderer
    ARG GO_TAGS
    RUN make orderer GO_TAGS=${GO_TAGS}
    
    FROM base
    ENV FABRIC_CFG_PATH /etc/hyperledger/fabric
    VOLUME /etc/hyperledger/fabric
    VOLUME /var/hyperledger
    COPY --from=orderer /go/src/github.com/hyperledger/fabric/build/bin /usr/local/bin
    COPY --from=orderer /go/src/github.com/hyperledger/fabric/sampleconfig/msp ${FABRIC_CFG_PATH}/msp
    COPY --from=orderer /go/src/github.com/hyperledger/fabric/sampleconfig/orderer.yaml ${FABRIC_CFG_PATH}
    COPY --from=orderer /go/src/github.com/hyperledger/fabric/sampleconfig/configtx.yaml ${FABRIC_CFG_PATH}
    EXPOSE 7050
    CMD ["orderer"]
  peer images/peer/Dockerfile
    # Copyright IBM Corp. All Rights Reserved.
    #
    # SPDX-License-Identifier: Apache-2.0
    
    ARG GO_VER
    ARG ALPINE_VER
    
    FROM rootfs:latest as peer-base
    #RUN apk add --no-cache tzdata
    RUN apt install tzdata --allow-unauthenticated -y
    # set up nsswitch.conf for Go's "netgo" implementation
    # - https://github.com/golang/go/blob/go1.9.1/src/net/conf.go#L194-L275
    # - docker run --rm debian:stretch grep '^hosts:' /etc/nsswitch.conf
    RUN echo 'hosts: files dns' > /etc/nsswitch.conf
    
    FROM golang:latest as golang
    RUN apt install bash --allow-unauthenticated -y
    RUN apt install gcc --allow-unauthenticated -y
    RUN apt install g++ --allow-unauthenticated -y
    RUN apt install git --allow-unauthenticated -y
    RUN apt install make --allow-unauthenticated -y
    RUN apt install musl-dev --allow-unauthenticated -y
    
    ADD . $GOPATH/src/github.com/hyperledger/fabric
    WORKDIR $GOPATH/src/github.com/hyperledger/fabric
    
    FROM golang as peer 
    ARG GO_TAGS
    RUN make peer GO_TAGS=${GO_TAGS}
    
    FROM peer-base
    ENV FABRIC_CFG_PATH /etc/hyperledger/fabric
    VOLUME /etc/hyperledger/fabric
    VOLUME /var/hyperledger
    COPY --from=peer /go/src/github.com/hyperledger/fabric/build/bin /usr/local/bin
    COPY --from=peer /go/src/github.com/hyperledger/fabric/sampleconfig/msp ${FABRIC_CFG_PATH}/msp
    COPY --from=peer /go/src/github.com/hyperledger/fabric/sampleconfig/core.yaml ${FABRIC_CFG_PATH}
    EXPOSE 7051
    CMD ["peer","node","start"]
make docker
5.2.7 部署
## 注意 baseos ccenv 版本 :2.2 
## 正常部署
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/649158.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号