-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Yann
committed
Sep 4, 2018
0 parents
commit 389038d
Showing
117 changed files
with
1,763 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
target/ | ||
**/target/ | ||
*.iml | ||
.idea/ | ||
/src/main/resources/rebel.xml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,172 @@ | ||
# Windows 10 64 bits Hyperledger Explorer full setup | ||
|
||
 | ||
|
||
## Prerequisites | ||
|
||
A running **Hyperledger Fabric** network. | ||
|
||
I used Hyperledger Fabric **v1.2**. | ||
See [Hyperledger Fabric documentation](https://hyperledger-fabric.readthedocs.io/en/release-1.2/). | ||
|
||
I included the configuration for an example network (_app/config/configtx.yaml_ and _app/config/crypto-config.yaml_ files). | ||
|
||
Also don't forget to configure **Git** for Windows : | ||
|
||
Check _autocrlf_ : | ||
|
||
```bash | ||
git config --get core.autocrlf | ||
``` | ||
|
||
if `null` or `true`, set it to `false` : | ||
|
||
```bash | ||
git config --global core.autocrlf false | ||
``` | ||
|
||
Check _longpaths_ : | ||
|
||
```bash | ||
git config --get core.longpaths | ||
``` | ||
|
||
if `null` or `false`, set it to `true` : | ||
|
||
```bash | ||
git config --global core.longpaths true | ||
``` | ||
|
||
## Cleaning | ||
|
||
In case you already set up the environment, here are some useful cleanup commands | ||
|
||
1. Clean all containers containing "blockchain-explorer" in their name | ||
|
||
```bash | ||
docker stop $(docker ps -a --filter="name=blockchain-explorer") | ||
docker rm $(docker ps -a --filter="name=blockchain-explorer") | ||
``` | ||
|
||
2. Clean all images with name starting with "hyperledger-blockchain-explorer" or "dev-peer" | ||
|
||
```bash | ||
docker rmi $(docker images hyperledger-blockchain-explorer* -q) | ||
``` | ||
|
||
3. Prune networks and volumes | ||
|
||
```bash | ||
docker network prune | ||
docker volume prune | ||
``` | ||
|
||
4. Remove crypto materials | ||
|
||
```bash | ||
rm -rf app/config/crypto-config/ | ||
``` | ||
|
||
## The network | ||
|
||
The Hyperledger network in which I ran this example is composed of : | ||
- 2 organizations : | ||
* myorg1 | ||
* myorg2 | ||
- 2 peers per organization : | ||
* myorg1 : peer0.myorg1.ch and peer1.myorg1.ch | ||
* myorg2 : peer0.myorg2.ch and peer1.myorg2.ch | ||
- peer0 from both organizations have been defined as anchor peer | ||
- all peers use _CouchDB_ as ledger state database | ||
- 1 user (identity) per peer (in addition to _Admin_ user) | ||
- 1 orderer (use its own channel _orderer-channel_) with _kafka_ consensus | ||
- 1 channel _my-channel_ joined by both peer0 from both organizations | ||
- 1 Go chaincode | ||
- 4 Kafka nodes and 3 Zookeeper (as recommended) | ||
|
||
See _app/config/configtx.yaml_ and _app/config/crypto-config.yaml_ for example configuration and [Hyperledger Fabric documentation](https://hyperledger-fabric.readthedocs.io/en/release-1.2/) for the setup. | ||
|
||
## Custom Docker setup | ||
|
||
I have build a custom setup, that I think is simpler than the proposed steps which consist of downloading the whole repository and then modify the files (as mentioned in the _readme_ file). | ||
|
||
Instead of downloading the repository locally and doing the modification in the sources, | ||
I get the repository directly into a Docker container and then link local configuration files to it using volumes. | ||
|
||
I have implemented a **Compose** file (_docker-compose.yaml_) that builds the images/containers for the application and the database. | ||
The containers will be attached to the existing Docker network of our Fabric network. | ||
|
||
The Application will attach to the database once it is ready (I used a `wait.sh` script to wait for the database to be up). | ||
|
||
So all that you need is in the _config_ directory : | ||
1. _config.json_ : file representing the network configuration | ||
2. _crypto-config_ : folder containing the network certificates | ||
|
||
You can regenerate the crypto materials from the _app/config/configtx.yaml_ and _app/config/crypto-config.yaml_ files. | ||
|
||
Then simply run : | ||
|
||
```bash | ||
docker-compose up | ||
``` | ||
|
||
This will run 2 containers : | ||
- `hyperledger_explorer_app` : the application | ||
- `hyperledger_explorer_postgresql` : the database | ||
|
||
You should be able to reach http://localhost:8092 | ||
|
||
For Swagger API endpoint, go to http://localhost:8092/api-docs/ | ||
|
||
## PostGreSQL database | ||
|
||
If you need to enter the PostGreSQL database manually, here are some useful commands : | ||
|
||
Get into the container : | ||
|
||
```bash | ||
winpty docker exec -it hyperledger_explorer_postgresql sh | ||
``` | ||
|
||
Connect to PostGreSQL as postgres user : | ||
|
||
```bash | ||
su postgres | ||
psql | ||
``` | ||
|
||
or : | ||
|
||
```bash | ||
psql -U postgres | ||
``` | ||
|
||
List all databases : | ||
|
||
```bash | ||
\list | ||
``` | ||
|
||
Connect to the `fabricexplorer` database : | ||
|
||
```bash | ||
\connect fabricexplorer | ||
``` | ||
|
||
Select data : | ||
|
||
```bash | ||
select * from peer; | ||
``` | ||
Quit : | ||
```bash | ||
\q | ||
``` | ||
## License | ||
For Hyperledger Explorer, see [LICENSE](https://github.com/hyperledger/blockchain-explorer/blob/master/LICENSE). | ||
Regarding the code I wrote, please refer to the [WTFPL](http://www.wtfpl.net/) license :) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
FROM node:8.11.3-alpine | ||
|
||
LABEL authors="Yann39, <[email protected]>" | ||
|
||
# environment variables | ||
ENV DATABASE_HOST postgresql | ||
ENV DATABASE_PORT 5432 | ||
ENV DATABASE_NAME fabricexplorer | ||
ENV DATABASE_USERNAME hppoc | ||
ENV DATABASE_PASSWD password | ||
|
||
# install required dependencies : python, make, g++, git | ||
RUN apk add --no-cache --virtual npm-deps python make g++ git && \ | ||
python -m ensurepip && \ | ||
rm -r /usr/lib/python*/ensurepip && \ | ||
pip install --upgrade pip setuptools && \ | ||
rm -r /root/.cache | ||
|
||
# install locate from findutils | ||
RUN apk add --no-cache findutils | ||
|
||
# install yarn and set permissions | ||
RUN npm install -g yarn && \ | ||
chmod 777 /usr/local/bin/yarn | ||
|
||
# get sources (only master branch and last revision) | ||
RUN git clone --single-branch -b master --depth 1 https://github.com/hyperledger/blockchain-explorer /opt/explorer | ||
|
||
# install NPM dependencies | ||
RUN cd /opt/explorer && npm install && npm build | ||
|
||
# copy local files to container | ||
COPY ./wait.sh /tmp/wait.sh | ||
|
||
# build explorer app | ||
RUN cd /opt/explorer && cd client && npm install && yarn build | ||
|
||
# remove installed packages to free space | ||
RUN apk del npm-deps |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
{ | ||
"network-config": { | ||
"org1": { | ||
"name": "MyOrg1", | ||
"mspid": "MyOrg1MSP", | ||
"peer1": { | ||
"requests": "grpcs://peer0.myorg1.ch:7051", | ||
"events": "grpcs://peer0.myorg1.ch:7053", | ||
"server-hostname": "peer0.myorg1.ch", | ||
"tls_cacerts": "/tmp/crypto/peerOrganizations/myorg1.ch/peers/peer0.myorg1.ch/tls/ca.crt" | ||
}, | ||
"peer2": { | ||
"requests": "grpcs://peer1.myorg1.ch:8051", | ||
"events": "grpcs://peer1.myorg1.ch:8053", | ||
"server-hostname": "peer1.myorg1.ch", | ||
"tls_cacerts": "/tmp/crypto/peerOrganizations/myorg1.ch/peers/peer1.myorg1.ch/tls/ca.crt" | ||
}, | ||
"admin": { | ||
"key": "/tmp/crypto/peerOrganizations/myorg1.ch/users/[email protected]/msp/keystore", | ||
"cert": "/tmp/crypto/peerOrganizations/myorg1.ch/users/[email protected]/msp/signcerts" | ||
} | ||
}, | ||
"org2": { | ||
"name": "MyOrg2", | ||
"mspid": "MyOrg2MSP", | ||
"peer1": { | ||
"requests": "grpcs://peer0.myorg2.ch:9051", | ||
"events": "grpcs://peer0.myorg2.ch:9053", | ||
"server-hostname": "peer0.myorg2.ch", | ||
"tls_cacerts": "/tmp/crypto/peerOrganizations/myorg2.ch/peers/peer0.myorg2.ch/tls/ca.crt" | ||
}, | ||
"peer2": { | ||
"requests": "grpcs://peer1.myorg2.ch:10051", | ||
"events": "grpcs://peer1.myorg2.ch:10053", | ||
"server-hostname": "peer1.myorg2.ch", | ||
"tls_cacerts": "/tmp/crypto/peerOrganizations/myorg2.ch/peers/peer1.myorg2.ch/tls/ca.crt" | ||
}, | ||
"admin": { | ||
"key": "/tmp/crypto/peerOrganizations/myorg2.ch/users/[email protected]/msp/keystore", | ||
"cert": "/tmp/crypto/peerOrganizations/myorg2.ch/users/[email protected]/msp/signcerts" | ||
} | ||
} | ||
}, | ||
"channel": "my-channel", | ||
"orderers": [{ | ||
"mspid": "OrdererMSP", | ||
"server-hostname": "orderer.myorg1.ch", | ||
"requests": "grpcs://orderer.myorg1.ch:7050", | ||
"tls_cacerts": "/tmp/crypto/ordererOrganizations/myorg1.ch/orderers/orderer.myorg1.ch/tls/ca.crt" | ||
}], | ||
"keyValueStore": "/tmp/fabric-client-kvs", | ||
"configtxgenToolPath": "fabric-path/fabric-samples/bin", | ||
"SYNC_START_DATE_FORMAT": "YYYY/MM/DD", | ||
"syncStartDate": "2018/01/01", | ||
"eventWaitTime": "30000", | ||
"license": "Apache-2.0", | ||
"version": "1.1" | ||
} |
Oops, something went wrong.