Warm tip: This article is reproduced from stackoverflow.com, please click
docker gradle corda

Corda Dockerform gradle task does not work as expected

发布于 2020-03-27 10:26:34

I have the following simple gradle task which I have created based on the information found here.

I have the following gradle task:

    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
    }
}

but when I run it, I get the following error:

No configuration setting found for key 'p2pAddress'

than I add p2pAddress "localhost" to all node's but after that I start to get this error:

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

can you please help me to get the task working, or give me a working example to fine out myself?

Questioner
Andranik
Viewed
154
Chris Chabot 2019-07-04 17:44

You're pretty close.

First make sure you've run ./gradlew deployNodes so that the node folder structure & files have been generated

Next the dockerform task in your build.gradle should look something like:

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"]]]
    }
}

Once deployNodes is done, create an empty docker-compose.yml file to work around the error you've gotten: touch workflows-java/build/nodes/docker-compose.yml

Then you can run ./gradlew prepareDockerNodes. Once that's done, edit the generated docker-compose.yml file to change the ports:

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"

And you should have a working situation again