---
apiVersion: batch/v1
kind: Job
metadata:
  namespace: org1
  name: chaincodeinstall
spec:
  backoffLimit: 1
  template:
    metadata:
      name: chaincodeinstall
    spec:
      restartPolicy: "Never"
      volumes:
        - name: sharedvolume
          persistentVolumeClaim:
            claimName: shared-pvc
      containers:
        - name: chaincodeinstall1
          image: hyperledger/fabric-tools:2.0
          command:
            [
              "sh",
              "-c",
              "echo $GOPATH; cp -r /shared/chaincode $GOPATH/src/; ls $GOPATH/src; cd $GOPATH/src/chaincode/chaincode_example02; go get; peer chaincode install -n ${CHAINCODE_NAME} -v ${CHAINCODE_VERSION} -p chaincode/chaincode_example02/",
            ]
          env:
            - name: CHAINCODE_NAME
              value: "cc"
            - name: CHAINCODE_VERSION
              value: "1.0"
            - name: FABRIC_CFG_PATH
              value: /etc/hyperledger/fabric
            - name: CORE_PEER_MSPCONFIGPATH
              value: /shared/crypto-config/peerOrganizations/org1/users/Admin@org1/msp
            - name: CORE_PEER_TLS_ROOTCERT_FILE
              value: /shared/crypto-config/peerOrganizations/org1/peers/peer0.org1/tls/ca.crt
            - name: CORE_PEER_LOCALMSPID
              value: Org1MSP
            - name: CORE_PEER_ADDRESS
              value: peer0.org1:7051
            - name: GODEBUG
              value: "netdns=go"
          volumeMounts:
            - mountPath: /shared
              name: sharedvolume
