Corda Dockerform gradle任务无法按预期运行

时间:2019-07-03 14:59:43

标签: docker corda

我有以下简单的gradle任务,该任务是根据here的信息创建的。

我有以下等级任务:

    task prepareDockerNodes(type: net.corda.plugins.Dockerform, dependsOn: ['jar']) {
    nodeDefaults{
        cordapp project(':tcw-contracts-states')
        cordapp project(':tcw-cordapp')
    }
    node {
        name "O=Notary Service,L=Zurich,C=CH"
        notary = [validating : false]
        rpcUsers = rpcUsersList
        useTestClock true
    }
    node {
        name "O=Bank A,L=London,C=GB"
        rpcUsers = rpcUsersList
        useTestClock true
    }
    node {
        name "O=Bank B,L=New York,C=US"
        rpcUsers = rpcUsersList
        useTestClock true
    }
}

但是当我运行它时,出现以下错误:

No configuration setting found for key 'p2pAddress'

然后我将p2pAddress "localhost"添加到所有节点,但是之后我开始出现此错误:

File 'build/nodes/docker-compose.yml' specified for property 'dockerComposePath' does not exist.

您能帮我完成任务,还是给我一个可行的例子来完善自己?

1 个答案:

答案 0 :(得分:1)

您非常接近。

首先请确保您已运行./gradlew deployNodes,以便已生成节点文件夹结构和文件

接下来,build.gradle中的dockerform任务应类似于:

task prepareDockerNodes(type: net.corda.plugins.Dockerform, dependsOn: ['jar']) {
    nodeDefaults {
        cordapp project(":contracts-java")
    }
    node {
        name "O=Notary,L=London,C=GB"
        notary = [validating : false]
        p2pPort 10002
        rpcSettings {
            address("localhost:10003")
            adminAddress("localhost:10023")
        }
        projectCordapp {
            deploy = false
        }
        cordapps.clear()
    }
    node {
        name "O=PartyA,L=London,C=GB"
        p2pPort 10002
        rpcSettings {
            address("localhost:10003")
            adminAddress("localhost:10023")
        }
        rpcUsers = [[user: "user1", "password": "test", "permissions": ["ALL"]]]
    }
    node {
        name "O=PartyB,L=New York,C=US"
        p2pPort 10002
        rpcSettings {
            address("localhost:10003")
            adminAddress("localhost:10023")
        }
        rpcUsers = [[user: "user1", "password": "test", "permissions": ["ALL"]]]
    }
}

deployNodes完成后,创建一个空的docker-compose.yml文件来解决您遇到的错误:touch workflows-java/build/nodes/docker-compose.yml

然后您可以运行./gradlew prepareDockerNodes。完成后,编辑生成的docker-compose.yml文件以更改端口:

version: '3'
services:
  notary:
    build: /Users/chrischabot/Projects/json-cordapp/workflows-java/build/nodes/Notary
    ports:
      - "10002"
      - "10003"
  partya:
    build: /Users/chrischabot/Projects/json-cordapp/workflows-java/build/nodes/PartyA
    ports:
      - "10002"
      - "10003"
  partyb:
    build: /Users/chrischabot/Projects/json-cordapp/workflows-java/build/nodes/PartyB
    ports:
    - "10002"
    - "10003"

然后您应该又可以工作了