Follow these steps to deploy the blockchain network layer.
1. Prerequisites
Ensure the following are installed on your Ubuntu environment:
- Node.js 12
- Docker & Docker-compose
- Redis
- FastDFS
- MySQL 8
- Go language environment
2. Pull and Tag Docker Images
Run the following commands to pull the required Fabric 1.2 images and tag them for local use:
# Pull images
docker pull hyperledger/fabric-peer:1.2.0 && \
docker pull hyperledger/fabric-orderer:1.2.0 && \
docker pull hyperledger/fabric-ca:1.2.0 && \
docker pull hyperledger/fabric-tools:1.2.0 && \
docker pull hyperledger/fabric-ccenv:1.2.0 && \
docker pull hyperledger/fabric-baseimage:0.4.10 && \
docker pull hyperledger/fabric-baseos:0.4.10 && \
docker pull hyperledger/fabric-couchdb:0.4.10
# Tag images
docker tag hyperledger/fabric-peer:1.2.0 hyperledger/fabric-peer && \
docker tag hyperledger/fabric-orderer:1.2.0 hyperledger/fabric-orderer && \
docker tag hyperledger/fabric-ca:1.2.0 hyperledger/fabric-ca && \
docker tag hyperledger/fabric-tools:1.2.0 hyperledger/fabric-tools && \
docker tag hyperledger/fabric-ccenv:1.2.0 hyperledger/fabric-ccenv && \
docker tag hyperledger/fabric-baseimage:0.4.10 hyperledger/fabric-baseimage && \
docker tag hyperledger/fabric-baseos:0.4.10 hyperledger/fabric-baseos && \
docker tag hyperledger/fabric-couchdb:0.4.10 hyperledger/fabric-couchdb
3. Initialize the Network
- Clone or upload the
blockchain-trace-bcnetwork repository to your server. - Navigate to the
basic_network directory and run the startup script:
chmod -R 777 start.sh
./start.sh
4. Initialize Webapp and Node.js Middleware
- Navigate to the
webapp directory and authorize the startup scripts:
chmod -R 777 startFarmerCC.sh
- Install dependencies:
npm install
(Note: Node.js 8 or 12 is recommended to avoid installation issues).
- Register users (Admin and Users):
node enrollAdmin.js
node registerUser.js
Troubleshooting: If registerUser.js fails, delete the hfc-key-store directory and try again.
- Start the Node.js middleware (connects frontend to Fabric):
node app.js
To run the service in the background, use pm2:
pm install pm2 -g # if not installed
pm2 start app.js
pm2 stop app.js
# Pulling and tagging images
docker pull hyperledger/fabric-peer:1.2.0 && \
docker tag hyperledger/fabric-peer:1.2.0 hyperledger/fabric-peer
# Starting the network
chmod -R 777 start.sh
./start.sh
# Starting the middleware
node app.js
# or with pm2
pm2 start app.js