version: '2'

services:
  couchdb2:
    container_name: couchdb2
    image: hyperledger/fabric-couchdb
#   Uncomment the port mapping if you want to expose the CouchDB service,
#   for example to utilize Fauxton User Interface in dev environments.
    volumes:
      - /var/hyperledger/couchdb2:/opt/couchdb/data 
    ports:
      - 5984:5984

  peer2:
    container_name: peer2
    image: hyperledger/fabric-peer
    environment:
      - CORE_NEXT=true
      - CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
      - CORE_PEER_ID=peer2
      - CORE_PEER_ENDORSER_ENABLED=true
      - CORE_PEER_LOCALMSPID=Org2MSP
      - CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/peer/
      - CORE_PEER_GOSSIP_ORGLEADER=true
      - CORE_PEER_ADDRESS=peer2:7051
      - CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer2:7051
      - CORE_PEER_TLS_ENABLED=true
      - CORE_PEER_TLS_KEY_FILE=/etc/hyperledger/tls/key.pem
      - CORE_PEER_TLS_CERT_FILE=/etc/hyperledger/tls/cert.pem
      - CORE_PEER_TLS_ROOTCERT_FILE=/etc/hyperledger/tls/ca-cert.pem
      # the following setting starts chaincode containers on the same
      # bridge network as the peers
      # https://docs.docker.com/compose/networking/
      - CORE_LEDGER_STATE_STATEDATABASE=CouchDB
      - CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS=couchdb2:5984
      - CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=fixtures_default
    working_dir: /opt/gopath/src/github.com/hyperledger/fabric
    command: peer node start --peer-defaultchain=false
    ports:
      - 8051:7051
      - 8053:7053
    volumes:
      - /var/run/:/host/var/run/
      - ./channel/crypto-config/peerOrganizations/peerOrg2/peers/peerOrg2Peer1/:/etc/hyperledger/msp/peer
      - ./tls/peers/peer2:/etc/hyperledger/tls
    depends_on:
      #- orderer0
      - couchdb2

