Merge pull request #5438 from corda/CORDA-3054-EdP

Update dockerform task steps
This commit is contained in:
edward-prosser 2019-09-05 15:33:40 +01:00 committed by GitHub
commit 7ef9a8d2c9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -7,9 +7,9 @@ Handcrafting a node
-------------------
A node can be created manually by creating a folder that contains the following items:
* The Corda JAR
* The Corda Enterprise JAR
* Can be downloaded from https://r3.bintray.com/corda/net/corda/corda/ (under /|corda_version|/corda-|corda_version|.jar)
* The binary ``corda-|corda_version|.jar`` provided to your organisation.
* A node configuration file entitled ``node.conf``, configured as per :doc:`corda-configuration-file`
@ -17,9 +17,9 @@ A node can be created manually by creating a folder that contains the following
* An up-to-date version of the ``network-parameters`` file ([see docs:](https://docs.corda.net/network-map.html#network-parameters)) generated by the bootstrapper tool
* **Optional:** A webserver JAR entitled ``corda-webserver.jar`` that will connect to the node via RPC
* **Optional:** A webserver JAR entitled ``corda-webserver-|corda_version|.jar`` that will connect to the node via RPC
* The (deprecated) default webserver can be downloaded from http://r3.bintray.com/corda/net/corda/corda-webserver/ (under /|corda_version|/corda-|corda_version|.jar)
* The (deprecated) default webserver is available to you for testing and should not be used in a production environment.
* A Spring Boot alternative can be found here: https://github.com/corda/spring-webserver
The remaining files and folders described in :doc:`node-structure` will be generated at runtime.
@ -34,15 +34,6 @@ in the `Kotlin CorDapp Template <https://github.com/corda/cordapp-template-kotli
task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) {
directory "./build/nodes"
nodeDefaults {
cordapps = [
"net.corda:corda-finance-contracts:$corda_release_version",
"net.corda:corda-finance-workflows:$corda_release_version",
"net.corda:corda-confidential-identities:$corda_release_version"
]
}
node {
name "O=Notary,L=London,C=GB"
// The notary will offer a validating notary service.
@ -56,6 +47,8 @@ in the `Kotlin CorDapp Template <https://github.com/corda/cordapp-template-kotli
h2Port 10004
// Starts an internal SSH server providing a management shell on the node.
sshdPort 2223
// Includes the corda-finance CorDapp on our node.
cordapps = ["$corda_release_distribution:corda-finance:$corda_release_version"]
extraConfig = [
// Setting the JMX reporter type.
jmxReporterType: 'JOLOKIA',
@ -72,6 +65,7 @@ in the `Kotlin CorDapp Template <https://github.com/corda/cordapp-template-kotli
}
webPort 10007
h2Port 10008
cordapps = ["$corda_release_distribution:corda-finance:$corda_release_version"]
// Grants user1 all RPC permissions.
rpcUsers = [[ user: "user1", "password": "test", "permissions": ["ALL"]]]
}
@ -84,11 +78,14 @@ in the `Kotlin CorDapp Template <https://github.com/corda/cordapp-template-kotli
}
webPort 10011
h2Port 10012
cordapps = ["$corda_release_distribution:corda-finance:$corda_release_version"]
// Grants user1 the ability to start the MyFlow flow.
rpcUsers = [[ user: "user1", "password": "test", "permissions": ["StartFlow.net.corda.flows.MyFlow"]]]
}
}
Ensure Corda Enterprise binaries are available on your machine as described in :ref:`Getting Set Up <resolve-corda-enterprise-binaries>`.
Running this task will create three nodes in the ``build/nodes`` folder:
* A ``Notary`` node that:
@ -240,6 +237,9 @@ Following the previous example ``PartyB`` node will have additional configuratio
}
}
Additional properties can be also specified directly by the ``extraConfig`` property which defines a map of keys and values. The example config above uses ``extraConfig`` to set value of the ``jvmArgs`` property.
See the extended example of :ref:`adding database configuration <testing_cordform_ref>`.
Cordform parameter `drivers` of the `node` entry lists paths of the files to be copied to the `./drivers` subdirectory of the node.
To copy the same file to all nodes `ext.drivers` can be defined in the top level and reused for each node via `drivers=ext.drivers``.
@ -368,8 +368,7 @@ The webserver JAR will be copied into the node's ``build`` folder with the name
The Dockerform task
-------------------
The ``Dockerform`` is a sister task of ``Cordform`` that provides an extra file allowing you to easily spin up
nodes using ``docker-compose``. It supports the following configuration options for each node:
The ``Dockerform`` is a sister task of ``Cordform`` that provides an extra file allowing you to easily spin up nodes using ``docker-compose``. It supports the following configuration options for each node:
* ``name``
* ``notary``
@ -377,69 +376,90 @@ nodes using ``docker-compose``. It supports the following configuration options
* ``rpcUsers``
* ``useTestClock``
There is no need to specify the nodes' ports, as every node has a separate container, so no ports conflict will occur.
Every node will expose port ``10003`` for RPC connections.
The nodes' webservers will not be started. Instead, you should interact with each node via its shell over SSH
(see the :doc:`node configuration options <corda-configuration-file>`). You have to enable the shell by adding the
The nodes' webservers will not be started. Instead, you should interact with each node via its shell over SSH
(see the :doc:`node configuration options <corda-configuration-file>`). You have to enable the shell by adding the
following line to each node's ``node.conf`` file:
``sshd { port = 2222 }``
``sshd { port = <NUMBER> }``
Where ``2222`` is the port you want to open to SSH into the shell.
Where ``<NUMBER>`` is the port you want to open to SSH into the shell.
Below you can find the example task from the `IRS Demo <|os_branch|/samples/irs-demo/cordapp/build.gradle#L111>`_ included in the samples directory of main Corda GitHub repository:
To run the Dockerform task, follow these steps:
.. sourcecode:: groovy
1. Run ``./gradlew deployNodes`` to generate the node files and folder structure.
def rpcUsersList = [
['username' : "user",
'password' : "password",
'permissions' : [
"StartFlow.net.corda.irs.flows.AutoOfferFlow\$Requester",
"StartFlow.net.corda.irs.flows.UpdateBusinessDayFlow\$Broadcast",
"StartFlow.net.corda.irs.api.NodeInterestRates\$UploadFixesFlow",
"InvokeRpc.vaultQueryBy",
"InvokeRpc.networkMapSnapshot",
"InvokeRpc.currentNodeTime",
"InvokeRpc.wellKnownPartyFromX500Name"
]]
]
2. Open the ``build.gradle`` file and add a new ``dockerform`` task after the existing ``deployNodes`` task:
// (...)
.. sourcecode:: groovy
task deployNodes(type: net.corda.plugins.Dockerform, dependsOn: ['jar']) {
nodeDefaults {
cordapps = [
"net.corda:corda-finance-contracts:$corda_release_version",
"net.corda:corda-finance-workflows:$corda_release_version",
"net.corda:corda-confidential-identities:$corda_release_version"
]
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"]]]
}
}
node {
name "O=Notary Service,L=Zurich,C=CH"
notary = [validating : true]
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
}
node {
name "O=Regulator,L=Moscow,C=RU"
rpcUsers = rpcUsersList
useTestClock true
}
}
3. Create an empty ``docker-compose.yml`` file using the following command on Mac or Linux:
``touch workflows-java/build/nodes/docker-compose.yml``
For Windows, use the following command:
``echo.> workflows-java\build\nodes\docker-compose.yml``
4. Run ``./gradlew prepareDockerNodes`` and edit the generated ``docker-compose.yml`` file to change the ports:
.. sourcecode:: groovy
version: '3'
services:
notary:
build: /Users/<USER>/Projects/json-cordapp/workflows-java/build/nodes/Notary
ports:
- "10002"
- "10003"
partya:
build: /Users/<USER>/Projects/json-cordapp/workflows-java/build/nodes/PartyA
ports:
- "10002"
- "10003"
partyb:
build: /Users/<USER>/Projects/json-cordapp/workflows-java/build/nodes/PartyB
ports:
- "10002"
- "10003"
Running the Cordform/Dockerform tasks
-------------------------------------
@ -455,6 +475,4 @@ for testing and development purposes. If you make any changes to your CorDapp so
need to re-run the task to see the changes take effect.
If the task is a ``Dockerform`` task, running the task will also create an additional ``Dockerfile`` in each node
directory, and a ``docker-compose.yml`` file in the ``build/nodes`` directory.
You can now run the nodes by following the instructions in :doc:`Running a node <running-a-node>`.
directory in the ``build/nodes`` directory.