# https://github.com/yeasy/docker-hyperledger-fabric-base## Dockerfile for Hyperledger fabric base image.# If you only need quickly deploy a fabric network, please see# * yeasy/hyperledger-fabric-peer# * yeasy/hyperledger-fabric-orderer# * yeasy/hyperledger-fabric-ca# Workdir is set to $GOPATH/src/github.com/hyperledger/fabric# Data is stored under /var/hyperledger/productionFROM golang:1.13LABEL maintainer "Baohua Yang <yeasy.github.com>"ENV DEBIAN_FRONTEND noninteractive# Only useful for this DockerfileENV FABRIC_ROOT=$GOPATH/src/github.com/hyperledger/fabricENV CHAINTOOL_RELEASE=1.1.3# version for the base images (baseos, baseimage, ccenv, etc.)ENV BASEIMAGE_RELEASE=0.4.18# BASE_VERSION is used in metadata.Version as major versionENV BASE_VERSION=2.0.0# PROJECT_VERSION is required in core.yaml for fabric-baseos and fabric-ccenvENV PROJECT_VERSION=2.0.0# generic golang cc builder environment (core.yaml): builder: $(DOCKER_NS)/fabric-ccenv:$(ARCH)-$(PROJECT_VERSION)ENV DOCKER_NS=hyperledger# for golang or car's baseos for cc runtime: $(BASE_DOCKER_NS)/fabric-baseos:$(ARCH)-$(BASEIMAGE_RELEASE)ENV BASE_DOCKER_NS=hyperledgerENV LD_FLAGS="-X github.com/hyperledger/fabric/common/metadata.Version=${PROJECT_VERSION} \-X github.com/hyperledger/fabric/common/metadata.BaseDockerLabel=org.hyperledger.fabric \-X github.com/hyperledger/fabric/common/metadata.DockerNamespace=hyperledger \-X github.com/hyperledger/fabric/common/metadata.BaseDockerNamespace=hyperledger"# -X github.com/hyperledger/fabric/common/metadata.Experimental=true \# -linkmode external -extldflags '-static -lpthread'"# Peer config pathENV FABRIC_CFG_PATH=/etc/hyperledger/fabricRUN mkdir -p /var/hyperledger/production \$GOPATH/src/github.com/hyperledger \$FABRIC_CFG_PATH \/chaincode/input \/chaincode/output# Install development dependenciesRUN apt-get update \&&apt-get install -y apt-utils python-dev \&&apt-get install -y libsnappy-dev zlib1g-dev libbz2-dev libyaml-dev libltdl-dev libtool \&&apt-get install -y python-pip \&&apt-get install -y vim tree jq unzip \&&rm -rf /var/cache/apt# Install chaintool#RUN curl -L https://github.com/hyperledger/fabric-chaintool/releases/download/v0.10.3/chaintool > /usr/local/bin/chaintool \RUN curl -fL https://nexus.hyperledger.org/content/repositories/releases/org/hyperledger/fabric/hyperledger-fabric/chaintool-${CHAINTOOL_RELEASE}/hyperledger-fabric-chaintool-${CHAINTOOL_RELEASE}.jar > /usr/local/bin/chaintool \&&chmod a+x /usr/local/bin/chaintool# install gotoolsRUN go get github.com/golang/protobuf/protoc-gen-go \&&go get github.com/maxbrunsfeld/counterfeiter \&&go get github.com/axw/gocov/... \&&go get github.com/AlekSi/gocov-xml \&&go get golang.org/x/tools/cmd/goimports \&&go get golang.org/x/lint/golint \&&go get github.com/estesp/manifest-tool \&&go get github.com/client9/misspell/cmd/misspell \&&go get github.com/estesp/manifest-tool \&&go get github.com/onsi/ginkgo/ginkgo# Clone the Hyperledger Fabric code and cp sample config filesRUN cd $GOPATH/src/github.com/hyperledger \&&wget https://github.com/hyperledger/fabric/archive/v${PROJECT_VERSION}-beta.zip \&&unzip v${PROJECT_VERSION}-beta.zip \&&rm v${PROJECT_VERSION}-beta.zip \&&mv fabric-${PROJECT_VERSION}-beta fabric \&&echo "* hard nofile 65536" >> /etc/security/limits.conf \&&echo "* soft nofile 65536" >> /etc/security/limits.conf \&&cp -r $FABRIC_ROOT/sampleconfig/* $FABRIC_CFG_PATH/# Add external farbric chaincode dependenciesRUN go get github.com/hyperledger/fabric-chaincode-go/shim \&&go get github.com/hyperledger/fabric-protos-go/peer# Install configtxgen, cryptogen, configtxlator, discover and idemixgenRUN cd $FABRIC_ROOT/ \&&CGO_CFLAGS=" " go install -tags "" github.com/hyperledger/fabric/cmd/configtxgen \&&CGO_CFLAGS=" " go install -tags "" github.com/hyperledger/fabric/cmd/cryptogen \&&CGO_CFLAGS=" " go install -tags "" github.com/hyperledger/fabric/cmd/configtxlator \&&CGO_CFLAGS=" " go install -tags "" -ldflags "-X github.com/hyperledger/fabric/cmd/discover/metadata.Version=2.0.0" github.com/hyperledger/fabric/cmd/discover \#&& CGO_CFLAGS=" " go install -tags "" -ldflags "-X github.com/hyperledger/fabric/cmd/token/metadata.Version=2.0.0" github.com/hyperledger/fabric/cmd/token \&&CGO_CFLAGS=" " go install -tags "" github.com/hyperledger/fabric/cmd/idemixgen# The data and config dir, can map external one with -vVOLUME /var/hyperledger# Temporarily fix the `go list` complain problem, which is required in chaincode packaging, see core/chaincode/platforms/golang/platform.go#GetDepoymentPayloadENV GOROOT=/usr/local/goWORKDIR $FABRIC_ROOT# This is only a workaround for current hard-coded problem when using as the fabric-baseimage.RUN ln -s $GOPATH /opt/gopathLABEL org.hyperledger.fabric.version=${PROJECT_VERSION} \org.hyperledger.fabric.base.version=${BASEIMAGE_RELEASE}
# https://github.com/yeasy/docker-hyperledger-fabric-peer## Dockerfile for Hyperledger peer image. This actually follow yeasy/hyperledger-fabric# image and add default start cmd.# Data is stored under /var/hyperledger/productionFROM yeasy/hyperledger-fabric-base:2.0.0LABEL maintainer "Baohua Yang <yeasy.github.io>"# PeerEXPOSE 7051# ENV CORE_PEER_MSPCONFIGPATH $FABRIC_CFG_PATH/msp# Install fabric peerRUN CGO_CFLAGS=" " go install -tags "" -ldflags "$LD_FLAGS" github.com/hyperledger/fabric/cmd/peer \&&go clean# First need to manually create a chain with `peer channel create -c test_chain`, then join with `peer channel join -b test_chain.block`.CMD ["peer","node","start"]
# https://github.com/yeasy/docker-hyperledger-fabric-ca## Dockerfile for Hyperledger fabric-ca image.# If you need a peer node to run, please see the yeasy/hyperledger-peer image.# Workdir is set to $GOPATH/src/github.com/hyperledger/fabric-ca# More usage infomation, please see https://github.com/yeasy/docker-hyperledger-fabric-ca.FROM golang:1.13LABEL maintainer "Baohua Yang <yeasy.github.com>"ENV PROJECT_VERSION 2.0.0# ca-server and ca-client will check the following env in order, to get the home cfg pathENV FABRIC_CA_HOME /etc/hyperledger/fabric-ca-serverENV FABRIC_CA_SERVER_HOME /etc/hyperledger/fabric-ca-serverENV FABRIC_CA_CLIENT_HOME $HOME/.fabric-ca-clientENV CA_CFG_PATH /etc/hyperledger/fabric-ca# This is to simplify this DockerfileENV FABRIC_CA_ROOT $GOPATH/src/github.com/hyperledger/fabric-ca# Usually the binary will be installed into $GOPATH/bin, but we add local build path, tooENV PATH=$FABRIC_CA_ROOT/bin:$PATH#ARG FABRIC_CA_DYNAMIC_LINK=false# fabric-ca-server will open service to '0.0.0.0:7054/api/v1/'EXPOSE 7054RUN mkdir -p $GOPATH/src/github.com/hyperledger \$FABRIC_CA_SERVER_HOME \$FABRIC_CA_CLIENT_HOME \$CA_CFG_PATH \/var/hyperledger/fabric-ca-server# Need libtool to provide the header file ltdl.hRUN apt-get update \&&apt-get install -y libtool unzip \&&rm -rf /var/cache/apt# Install yq to update config for fabric-caRUN wget -O /go/bin/yq https://github.com/mikefarah/yq/releases/download/2.4.1/yq_linux_amd64 \&&chmod a+x /go/bin/yq# clone and build caRUN cd $GOPATH/src/github.com/hyperledger \&&wget https://github.com/hyperledger/fabric-ca/archive/v${PROJECT_VERSION}.zip \&&unzip v${PROJECT_VERSION}.zip \&&rm v${PROJECT_VERSION}.zip \&&mv fabric-ca-${PROJECT_VERSION} fabric-ca \# This will install fabric-ca-server and fabric-ca-client into $GOPATH/bin/&&go install -ldflags "-X github.com/hyperledger/fabric-ca/lib/metadata.Version=$PROJECT_VERSION -linkmode external -extldflags '-static -lpthread'" github.com/hyperledger/fabric-ca/cmd/... \# Copy example ca and key files#&& cp $FABRIC_CA_ROOT/images/fabric-ca/payload/*.pem $FABRIC_CA_HOME/ \&&go cleanVOLUME $FABRIC_CA_SERVER_HOMEVOLUME $FABRIC_CA_CLIENT_HOMEWORKDIR $FABRIC_CA_ROOT# if no config exists under $FABRIC_CA_HOME, will init fabric-ca-server-config.yaml and fabric-ca-server.dbCMD ["bash", "-c", "fabric-ca-server start -b admin:adminpw"]#CMD ["bash", "-c", "fabric-ca-server start --ca.certfile $FABRIC_CA_HOME/ca-cert.pem --ca.keyfile $FABRIC_CA_HOME/ca-key.pem -b admin:adminpw -n test_ca"]