From 2bdc0569066c31fbb623eabf32cbf86a6631fd60 Mon Sep 17 00:00:00 2001 From: yosaphatprs Date: Fri, 5 Dec 2025 16:33:55 +0700 Subject: [PATCH] feat: done setup multipeer on 3 pc --- backend/api/.gitignore | 1 + .../network/docker/docker-compose-swarm.yaml | 168 ++++++++++++++++++ 2 files changed, 169 insertions(+) create mode 100644 backend/blockchain/network/docker/docker-compose-swarm.yaml diff --git a/backend/api/.gitignore b/backend/api/.gitignore index 2dc23cb..609998b 100644 --- a/backend/api/.gitignore +++ b/backend/api/.gitignore @@ -56,3 +56,4 @@ pids report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json /src/generated/prisma +/blockchain/backup \ No newline at end of file diff --git a/backend/blockchain/network/docker/docker-compose-swarm.yaml b/backend/blockchain/network/docker/docker-compose-swarm.yaml new file mode 100644 index 0000000..1e19dbd --- /dev/null +++ b/backend/blockchain/network/docker/docker-compose-swarm.yaml @@ -0,0 +1,168 @@ +version: "3.8" + +networks: + hospital_net: + external: true + name: hospital_net + +services: + orderer: + image: hyperledger/fabric-orderer:2.5 + hostname: orderer.hospital.com + environment: + - FABRIC_LOGGING_SPEC=INFO + - ORDERER_GENERAL_LISTENADDRESS=0.0.0.0 + - ORDERER_GENERAL_LISTENPORT=7050 + - ORDERER_GENERAL_GENESISMETHOD=file + - ORDERER_GENERAL_GENESISFILE=/var/hyperledger/orderer/orderer.genesis.block + - ORDERER_GENERAL_LOCALMSPID=OrdererMSP + - ORDERER_GENERAL_LOCALMSPDIR=/var/hyperledger/orderer/msp + - ORDERER_GENERAL_TLS_ENABLED=true + - ORDERER_GENERAL_TLS_PRIVATEKEY=/var/hyperledger/orderer/tls/server.key + - ORDERER_GENERAL_TLS_CERTIFICATE=/var/hyperledger/orderer/tls/server.crt + - ORDERER_GENERAL_TLS_ROOTCAS=[/var/hyperledger/orderer/tls/ca.crt] + - ORDERER_KAFKA_TOPIC_REPLICATIONFACTOR=1 + - ORDERER_KAFKA_VERBOSE=true + - ORDERER_GENERAL_CLUSTER_CLIENTCERTIFICATE=/var/hyperledger/orderer/tls/server.crt + - ORDERER_GENERAL_CLUSTER_CLIENTPRIVATEKEY=/var/hyperledger/orderer/tls/server.key + - ORDERER_GENERAL_CLUSTER_ROOTCAS=[/var/hyperledger/orderer/tls/ca.crt] + working_dir: /opt/gopath/src/github.com/hyperledger/fabric + command: orderer + volumes: + - /home/labai1/josafat/hospital-log/backend/blockchain/network/channel-artifacts/genesis.block:/var/hyperledger/orderer/orderer.genesis.block + - /home/labai1/josafat/hospital-log/backend/blockchain/network/organizations/ordererOrganizations/hospital.com/orderers/orderer.hospital.com/msp:/var/hyperledger/orderer/msp + - /home/labai1/josafat/hospital-log/backend/blockchain/network/organizations/ordererOrganizations/hospital.com/orderers/orderer.hospital.com/tls:/var/hyperledger/orderer/tls + - /home/labai1/josafat/hospital-log/backend/blockchain/backup/orderer:/var/hyperledger/production/orderer + ports: + - "7050:7050" + networks: + hospital_net: + aliases: + - orderer.hospital.com + deploy: + placement: + constraints: + - node.labels.lokasi == pc-kiri + + peer0: + image: hyperledger/fabric-peer:2.5 + hostname: peer0.hospital.com + environment: + - CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock + - CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=hospital_net + - FABRIC_LOGGING_SPEC=INFO + - CORE_PEER_TLS_ENABLED=true + - CORE_PEER_PROFILE_ENABLED=true + - CORE_PEER_ID=peer0.hospital.com + - CORE_PEER_ADDRESS=peer0.hospital.com:7051 + - CORE_PEER_LISTENADDRESS=0.0.0.0:7051 + - CORE_PEER_CHAINCODEADDRESS=peer0.hospital.com:7052 + - CORE_PEER_CHAINCODELISTENADDRESS=0.0.0.0:7052 + - CORE_PEER_GOSSIP_BOOTSTRAP=peer1.hospital.com:8051 + - CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer0.hospital.com:7051 + - CORE_PEER_LOCALMSPID=HospitalMSP + volumes: + - /var/run/docker.sock:/host/var/run/docker.sock + - /home/labai1/josafat/hospital-log/backend/blockchain/network/organizations/peerOrganizations/hospital.com/peers/peer0.hospital.com/msp:/etc/hyperledger/fabric/msp + - /home/labai1/josafat/hospital-log/backend/blockchain/network/organizations/peerOrganizations/hospital.com/peers/peer0.hospital.com/tls:/etc/hyperledger/fabric/tls + - /home/labai1/josafat/hospital-log/backend/blockchain/backup/peer0:/var/hyperledger/production + ports: + - "7051:7051" + networks: + hospital_net: + aliases: + - peer0.hospital.com + deploy: + placement: + constraints: + - node.labels.lokasi == pc-kiri + + cli: + image: hyperledger/fabric-tools:2.5 + tty: true + stdin_open: true + environment: + - GOPATH=/opt/gopath + - CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock + - FABRIC_LOGGING_SPEC=INFO + - CORE_PEER_TLS_ENABLED=true + - CORE_PEER_LOCALMSPID=HospitalMSP + - CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/organizations/peerOrganizations/hospital.com/peers/peer0.hospital.com/tls/ca.crt + - CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/organizations/peerOrganizations/hospital.com/users/Admin@hospital.com/msp + - CORE_PEER_ADDRESS=peer0.hospital.com:7051 + working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer + command: /bin/bash + volumes: + - /var/run/docker.sock:/host/var/run/docker.sock + - /home/labai1/josafat/hospital-log/backend/blockchain/chaincode:/opt/gopath/src/github.com/hyperledger/fabric/peer/chaincode + - /home/labai1/josafat/hospital-log/backend/blockchain/network/organizations:/opt/gopath/src/github.com/hyperledger/fabric/peer/organizations + - /home/labai1/josafat/hospital-log/backend/blockchain/network/channel-artifacts:/opt/gopath/src/github.com/hyperledger/fabric/peer/channel-artifacts + depends_on: + - orderer + - peer0 + networks: + - hospital_net + deploy: + placement: + constraints: + - node.labels.lokasi == pc-kiri + + peer1: + image: hyperledger/fabric-peer:2.5 + hostname: peer1.hospital.com + environment: + - CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock + - CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=hospital_net + - FABRIC_LOGGING_SPEC=INFO + - CORE_PEER_TLS_ENABLED=true + - CORE_PEER_PROFILE_ENABLED=true + - CORE_PEER_ID=peer1.hospital.com + - CORE_PEER_ADDRESS=peer1.hospital.com:8051 + - CORE_PEER_LISTENADDRESS=0.0.0.0:8051 + - CORE_PEER_CHAINCODEADDRESS=peer1.hospital.com:7052 + - CORE_PEER_CHAINCODELISTENADDRESS=0.0.0.0:7052 + - CORE_PEER_GOSSIP_BOOTSTRAP=peer0.hospital.com:7051 + - CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer1.hospital.com:8051 + - CORE_PEER_LOCALMSPID=HospitalMSP + volumes: + - /var/run/docker.sock:/host/var/run/docker.sock + - /home/labai2/josafat/hospital-log/backend/blockchain/network/organizations/peerOrganizations/hospital.com/peers/peer1.hospital.com/msp:/etc/hyperledger/fabric/msp + - /home/labai2/josafat/hospital-log/backend/blockchain/network/organizations/peerOrganizations/hospital.com/peers/peer1.hospital.com/tls:/etc/hyperledger/fabric/tls + ports: + - "8051:8051" + networks: + - hospital_net + deploy: + placement: + constraints: + - node.labels.lokasi == pc-tengah + + peer2: + image: hyperledger/fabric-peer:2.5 + hostname: peer2.hospital.com + environment: + - CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock + - CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=hospital_net + - FABRIC_LOGGING_SPEC=INFO + - CORE_PEER_TLS_ENABLED=true + - CORE_PEER_PROFILE_ENABLED=true + - CORE_PEER_ID=peer2.hospital.com + - CORE_PEER_ADDRESS=peer2.hospital.com:9051 + - CORE_PEER_LISTENADDRESS=0.0.0.0:9051 + - CORE_PEER_CHAINCODEADDRESS=peer2.hospital.com:7052 + - CORE_PEER_CHAINCODELISTENADDRESS=0.0.0.0:7052 + - CORE_PEER_GOSSIP_BOOTSTRAP=peer0.hospital.com:7051 + - CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer2.hospital.com:9051 + - CORE_PEER_LOCALMSPID=HospitalMSP + volumes: + - /var/run/docker.sock:/host/var/run/docker.sock + - /run/desktop/mnt/host/c/fabric-data/network/organizations/peerOrganizations/hospital.com/peers/peer2.hospital.com/msp:/etc/hyperledger/fabric/msp + - /run/desktop/mnt/host/c/fabric-data/network/organizations/peerOrganizations/hospital.com/peers/peer2.hospital.com/tls:/etc/hyperledger/fabric/tls + ports: + - "9051:9051" + networks: + - hospital_net + deploy: + placement: + constraints: + - node.labels.lokasi == pc-kanan