国产银河麒麟arm64架构部署fabric2.2

国产银河麒麟arm64架构部署fabric2.2,第1张

1. 构建golang环境
## 直接下载包 安装即可

wget https://studygolang.com/dl/golang/go1.16.10.linux-arm64.tar.gz
## 具体安装不陈述了 设置环境变量 source *** 更新一下
2. 构建fabric-ca
make fabric-ca-client

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

## 其他注意本地native部署配置环境等等就行
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
 
 dpkg -i 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 \0/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/pkg/*/cmd \
    		/usr/local/go/pkg/bootstrap \
    		/usr/local/go/pkg/obj \
    		/usr/local/go/pkg/tool/*/api \
    		/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
## 注意Dockerfile FROM依赖rootfs:latest的tag 把上一步自建基础镜像改一下tag
 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"]
5.2.7 部署
## 注意 baseos ccenv 版本 :2.2 
## 正常部署

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/994966.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-21
下一篇 2022-05-21

发表评论

登录后才能评论

评论列表(0条)

保存