M2-Macbook install hyperledger explorer-docker way, install by hand

There are some problems with the installation of the M2 chip according to the official tutorial, record and share the solutions to various pits

The official tutorial is as follows

GitHub – hyperledger-labs/blockchain-explorer

This article is the docker method

1. Prerequisites

According to the official

Docker related dependencies, hyperfavric ledger, etc.

2. Start the fabric network

Official guide: Hyperledger Fabric official tutorial
By default, you have already configured the fabric test network (test-network)

3. Refer to the official website and the blogger’s sharing

http://t.csdn.cn/hMj4y

3.1 Configuration file

a. Create a new directory (eg explorer)

Create an explorer folder directly under the test-network folder:

mkdir explorer
cd explorer

b. Copy the following files from the repository

wget https://raw.githubusercontent.com/hyperledger/blockchain-explorer/master/examples/net1/config.json
wget https://raw.githubusercontent.com/hyperledger/blockchain-explorer/master/examples/net1/connection-profile/test-network.json -P connection-profile
wget https://raw.githubusercontent.com/hyperledger/blockchain-explorer/master/docker-compose.yaml

c. Copy the entire encrypted artifacts directory (organizations/) from your fabric network (e.g. /fabric-samples/test-network)

cp -rf organizations explorer

Copy the organizations file in test-network into explorer (my directory is as follows)

d. After the explorer is configured, you should have the following file and directory structure.

3.2 Modify files

a. Edit the environment variables in docker-compose. Align with your environment

# SPDX-License-Identifier: Apache-2.0
version: ‘2.1’

volumes:
pgdata:
walletstore:

networks:
mynetwork.com:
external:
name: fabric_test

services:

explorerdb.mynetwork.com:
image: hyperledger/explorer-db:latest
container_name: explorerdb.mynetwork.com
platform: linux/amd64
hostname: explorerdb.mynetwork.com
environment:
– DATABASE_DATABASE=fabricexplorer
– DATABASE_USERNAME=hppoc
– DATABASE_PASSWORD=password
healthcheck:
test: “pg_isready -h localhost -p 5432 -q -U postgres”
interval: 30s
timeout: 10s
retries: 5
volumes:
– pgdata:/var/lib/postgresql/data
networks:
-mynetwork.com

explorer.mynetwork.com:

image: hyperledger/explorer:latest

container_name: explorer.mynetwork.com

platform: linux/amd64

hostname: explorer.mynetwork.com

environment:

– DATABASE_HOST=explorerdb.mynetwork.com

– DATABASE_DATABASE=fabricexplorer

– DATABASE_USERNAME=hppoc

– DATABASE_PASSWD=password

– LOG_LEVEL_APP=info

– LOG_LEVEL_DB=info

– LOG_LEVEL_CONSOLE=debug

– LOG_CONSOLE_STDOUT=true

– DISCOVERY_AS_LOCALHOST=false

– PORT=${PORT:-8080}

volumes:

– ./config.json:/opt/explorer/app/platform/fabric/config.json

– ./connection-profile:/opt/explorer/app/platform/fabric/connection-profile

– ./organizations:/tmp/crypto

– walletstore:/opt/explorer/wallet

ports:

– ${PORT:-8080}:${PORT:-8080}

depends_on:

explorerdb.mynetwork.com:

condition: service_healthy

networks:

-mynetwork.com

Pay attention to the red part, the m2 chip needs to indicate the platform, otherwise it will report an error when starting docker.

The name part should be consistent with your network name. If your network defaults to net_test, you don’t need to modify it.
(View docker network command: docker network ls)

I am here fabric_test

b. Replace the user’s certificate with the admin certificate and secret (private) key in the connection configuration file (test-network.json). You need to specify an absolute path on the Explorer container.

Modify connection profile

cd connection-profile
vim test-network.json

{

“name”: “test-network”,

“version”: “1.0.0”,

“client”: {

“tlsEnable”: true,

“adminCredential”: {

“id”: “exploreradmin”,

“password”: “exploreradminpw”

},

“enableAuthentication”: true,

“organization”: “Org1MSP”,

“connection”: {

“timeout”: {

“peer”: {

“endorser”: “300”

},

“orderer”: “300”

}

}

},

“channels”: {

“mychannel”: {

“peers”: {

“peer0.org1.example.com”: {}

}

}

},

“organizations”: {

“Org1MSP”: {

“mspid”: “Org1MSP”,

“adminPrivateKey”: {

“path”: “/tmp/crypto/peerOrganizations/org1.example.com/users/[email protected]/msp/keystore/priv_sk”

},

“peers”: [“peer0.org1.example.com”],

“signedCert”: {

“path”: “/tmp/crypto/peerOrganizations/org1.example.com/users/[email protected]/msp/signcerts/[email protected]

}

}

},

“peers”: {

“peer0.org1.example.com”: {

“tlsCACerts”: {

“path”: “/tmp/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt”

},

“url”: “grpcs://peer0.org1.example.com:7051”

}

}

}

The blue mark is the user name and password

Attention to modify the red mark

4. Start the container

docker-compose up -d

5. Access using explorer

Enter in the address bar: http://localhost:8080/

after login