Skip to content

Commit f538423

Browse files
committed
initial commit of docker-compose sample
1 parent 5fd2232 commit f538423

File tree

23 files changed

+1051
-0
lines changed

23 files changed

+1051
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Copyright 2016, R3 Limited.
2+
3+
Licensed under the Apache License, Version 2.0 (the "License");
4+
you may not use this file except in compliance with the License.
5+
You may obtain a copy of the License at
6+
7+
http://www.apache.org/licenses/LICENSE-2.0
8+
9+
Unless required by applicable law or agreed to in writing, software
10+
distributed under the License is distributed on an "AS IS" BASIS,
11+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
See the License for the specific language governing permissions and
13+
limitations under the License.
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# dockerform-yocordapp
2+
3+
This time we've taken the original yo cordapp and modified it to demonstrate an example of how you can use dockerForm to bootstrap a corda network.
4+
5+
For the purposes of this example, we'll use the yo cordapp as a base to create a clear example for how to use the dockerForm gradle build task in a normal cordapp setup.
6+
7+
> Note this is generally intended to be used on localhost.
8+
9+
10+
## Concepts
11+
12+
In the original yo application, the app sent what is essentially a nudge from one endpoint and another.
13+
14+
In corda, we can use abstractions to accomplish the same thing.
15+
16+
17+
We define a state (the yo to be shared), define a contract (the way to make sure the yo is legit), and define the flow (the control flow of our cordapp).
18+
19+
20+
## Usage
21+
22+
### Quick Start with Docker
23+
24+
If you have docker installed you can use our gradle tasks to generate a valid docker compose file for your node configuration.
25+
26+
```bash
27+
# clone the repository
28+
git clone https://github.com/davidawad/corda-docker-yo-demo && cd corda-docker-yo-demo
29+
30+
# generate the docker-compose file
31+
./gradlew prepareDockerNodes
32+
33+
# run our corda network
34+
docker-compose -f ./build/nodes/docker-compose.yml up
35+
```
36+
37+
#### Sending a Yo
38+
39+
We will interact with the nodes via their specific shells. When the nodes are up and running, use the following command to send a Yo to another node:
40+
41+
```sh
42+
# find the ssh port for PartyA using docker ps
43+
ssh [email protected] -p 2223
44+
45+
# the password defined in the node config for PartyA is "test"
46+
Password: test
47+
48+
49+
Welcome to the Corda interactive shell.
50+
You can see the available commands by typing 'help'.
51+
52+
# you'll see the corda shell available and can run flows
53+
Fri May 15 18:23:03 GMT 2020>>> flow start YoFlow target: PartyB
54+
55+
✓ Starting
56+
✓ Creating a new Yo!
57+
✓ Signing the Yo!
58+
✓ Verfiying the Yo!
59+
✓ Sending the Yo!
60+
Requesting signature by notary service
61+
Requesting signature by Notary service
62+
Validating response from Notary service
63+
✓ Broadcasting transaction to participants
64+
▶︎ Done
65+
Flow completed with result: SignedTransaction(id=3F92F41B699719B2CDE578959BB09F50D3D4F5D51A496DEAB67E438B2614F48C)
66+
```
67+
68+
Once this runs on your machine you've got everything you would need to run corda for development using docker!
69+
70+
###### Note you can't send a Yo! to yourself because that's not cool!
71+
72+
To see all the Yo's other nodes have sent you in your vault you can run a vault query from the Corda shell:
73+
74+
```bash
75+
run vaultQuery contractStateType: net.corda.examples.yo.states.YoState
76+
```
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Corda and the Corda logo are trademarks of R3CEV LLC and its affiliates. All rights reserved.
2+
3+
For R3CEV LLC's trademark and logo usage information, please consult our Trademark Usage Policy at
4+
https://www.r3.com/trademark-policy/.
Lines changed: 190 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,190 @@
1+
buildscript {
2+
Properties constants = new Properties()
3+
file("$projectDir/../constants.properties").withInputStream { constants.load(it) }
4+
5+
ext {
6+
corda_release_group = constants.getProperty("cordaReleaseGroup")
7+
corda_core_release_group = constants.getProperty("cordaCoreReleaseGroup")
8+
corda_release_version = constants.getProperty("cordaVersion")
9+
corda_core_release_version = constants.getProperty("cordaCoreVersion")
10+
corda_gradle_plugins_version = constants.getProperty("gradlePluginsVersion")
11+
kotlin_version = constants.getProperty("kotlinVersion")
12+
junit_version = constants.getProperty("junitVersion")
13+
quasar_version = constants.getProperty("quasarVersion")
14+
log4j_version = constants.getProperty("log4jVersion")
15+
slf4j_version = constants.getProperty("slf4jVersion")
16+
corda_platform_version = constants.getProperty("platformVersion").toInteger()
17+
}
18+
19+
repositories {
20+
mavenLocal()
21+
mavenCentral()
22+
jcenter()
23+
maven { url 'https://software.r3.com/artifactory/corda-releases' }
24+
}
25+
26+
dependencies {
27+
classpath "net.corda.plugins:cordapp:$corda_gradle_plugins_version"
28+
classpath "net.corda.plugins:cordformation:$corda_gradle_plugins_version"
29+
classpath "net.corda.plugins:quasar-utils:$corda_gradle_plugins_version"
30+
}
31+
}
32+
33+
allprojects {
34+
apply from: "${rootProject.projectDir}/repositories.gradle"
35+
apply plugin: 'java'
36+
37+
repositories {
38+
mavenLocal()
39+
jcenter()
40+
mavenCentral()
41+
maven { url 'https://software.r3.com/artifactory/corda' }
42+
maven { url 'https://jitpack.io' }
43+
}
44+
45+
tasks.withType(JavaCompile) {
46+
options.compilerArgs << "-parameters" // Required for shell commands.
47+
}
48+
49+
jar {
50+
// This makes the JAR's SHA-256 hash repeatable.
51+
preserveFileTimestamps = false
52+
reproducibleFileOrder = true
53+
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
54+
}
55+
}
56+
57+
apply plugin: 'net.corda.plugins.cordapp'
58+
apply plugin: 'net.corda.plugins.cordformation'
59+
apply plugin: 'net.corda.plugins.quasar-utils'
60+
61+
sourceSets {
62+
main {
63+
resources {
64+
srcDir rootProject.file("config/dev")
65+
}
66+
}
67+
}
68+
69+
dependencies {
70+
// Corda dependencies.
71+
cordaCompile "$corda_core_release_group:corda-core:$corda_core_release_version"
72+
cordaCompile "$corda_release_group:corda-node-api:$corda_release_version"
73+
cordaRuntime "$corda_release_group:corda:$corda_release_version"
74+
75+
// CorDapp dependencies.
76+
cordapp project(":workflows")
77+
cordapp project(":contracts")
78+
79+
cordaCompile "org.apache.logging.log4j:log4j-slf4j-impl:${log4j_version}"
80+
cordaCompile "org.apache.logging.log4j:log4j-web:${log4j_version}"
81+
cordaCompile "org.slf4j:jul-to-slf4j:$slf4j_version"
82+
}
83+
84+
cordapp {
85+
info {
86+
name "CorDapp yo"
87+
vendor "Corda Open Source"
88+
targetPlatformVersion corda_platform_version
89+
minimumPlatformVersion corda_platform_version
90+
}
91+
}
92+
93+
94+
task deployNodesJava(type: net.corda.plugins.Cordform, dependsOn: ['jar']) {
95+
96+
nodeDefaults {
97+
projectCordapp {
98+
deploy = false
99+
}
100+
cordapp project("contracts")
101+
cordapp project("workflows")
102+
rpcUsers = [[ user: "user1", "password": "test", "permissions": ["ALL"]]]
103+
}
104+
105+
node {
106+
name "O=Notary,L=London,C=GB"
107+
notary = [validating : false]
108+
p2pPort 10001
109+
p2pAddress "0.0.0.0"
110+
rpcSettings {
111+
address("0.0.0.0:10011")
112+
adminAddress("0.0.0.0:10041")
113+
}
114+
sshdPort 2221
115+
}
116+
117+
node {
118+
name "O=PartyA,L=London,C=GB"
119+
p2pPort 10002
120+
p2pAddress "0.0.0.0"
121+
rpcSettings {
122+
address("0.0.0.0:10012")
123+
adminAddress("0.0.0.0:10042")
124+
}
125+
sshdPort 2222
126+
}
127+
128+
node {
129+
name "O=PartyB,L=New York,C=US"
130+
p2pPort 10003
131+
p2pAddress "0.0.0.0"
132+
rpcSettings {
133+
address("0.0.0.0:10013")
134+
adminAddress("0.0.0.0:10043")
135+
}
136+
sshdPort 2223
137+
}
138+
139+
}
140+
141+
142+
task prepareDockerNodes(type: net.corda.plugins.Dockerform, dependsOn: ['jar']) {
143+
144+
dockerImage="corda/corda-zulu-java1.8-"+corda_release_version+":latest"
145+
146+
nodeDefaults {
147+
projectCordapp {
148+
deploy = false
149+
}
150+
cordapp project("contracts")
151+
cordapp project("workflows")
152+
rpcUsers = [[ user: "user1", "password": "test", "permissions": ["ALL"]]]
153+
}
154+
155+
node {
156+
name "O=Notary,L=London,C=GB"
157+
notary = [validating : false]
158+
p2pPort 10001
159+
p2pAddress "0.0.0.0"
160+
rpcSettings {
161+
address("0.0.0.0:10011")
162+
adminAddress("0.0.0.0:10041")
163+
}
164+
sshdPort 2221
165+
}
166+
167+
node {
168+
name "O=PartyA,L=London,C=GB"
169+
p2pPort 10002
170+
p2pAddress "0.0.0.0"
171+
rpcSettings {
172+
address("0.0.0.0:10012")
173+
adminAddress("0.0.0.0:10042")
174+
}
175+
sshdPort 2222
176+
}
177+
178+
node {
179+
name "O=PartyB,L=New York,C=US"
180+
p2pPort 10003
181+
p2pAddress "0.0.0.0"
182+
rpcSettings {
183+
address("0.0.0.0:10013")
184+
adminAddress("0.0.0.0:10043")
185+
}
186+
sshdPort 2223
187+
}
188+
}
189+
190+
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Configuration status="info">
3+
4+
<Properties>
5+
<Property name="log-path">logs</Property>
6+
<Property name="log-name">node-${hostName}</Property>
7+
<Property name="archive">${log-path}/archive</Property>
8+
</Properties>
9+
10+
<ThresholdFilter level="trace"/>
11+
12+
<Appenders>
13+
<Console name="Console-Appender" target="SYSTEM_OUT">
14+
<PatternLayout>
15+
<pattern>
16+
%highlight{%level{length=1} %d{HH:mm:ss} %T %c{1}.%M - %msg%n}{INFO=white,WARN=red,FATAL=bright red blink}
17+
</pattern>>
18+
</PatternLayout>
19+
</Console>
20+
21+
<!-- Will generate up to 10 log files for a given day. During every rollover it will delete
22+
those that are older than 60 days, but keep the most recent 10 GB -->
23+
<RollingFile name="RollingFile-Appender"
24+
fileName="${log-path}/${log-name}.log"
25+
filePattern="${archive}/${log-name}.%d{yyyy-MM-dd}-%i.log.gz">
26+
27+
<PatternLayout pattern="[%-5level] %d{ISO8601}{GMT+0} [%t] %c{1} - %msg%n"/>
28+
29+
<Policies>
30+
<TimeBasedTriggeringPolicy/>
31+
<SizeBasedTriggeringPolicy size="10MB"/>
32+
</Policies>
33+
34+
<DefaultRolloverStrategy min="1" max="10">
35+
<Delete basePath="${archive}" maxDepth="1">
36+
<IfFileName glob="${log-name}*.log.gz"/>
37+
<IfLastModified age="60d">
38+
<IfAny>
39+
<IfAccumulatedFileSize exceeds="10 GB"/>
40+
</IfAny>
41+
</IfLastModified>
42+
</Delete>
43+
</DefaultRolloverStrategy>
44+
45+
</RollingFile>
46+
</Appenders>
47+
48+
<Loggers>
49+
<Root level="info">
50+
<AppenderRef ref="Console-Appender"/>
51+
<AppenderRef ref="RollingFile-Appender"/>
52+
</Root>
53+
<Logger name="net.corda" level="info" additivity="false">
54+
<AppenderRef ref="Console-Appender"/>
55+
<AppenderRef ref="RollingFile-Appender"/>
56+
</Logger>
57+
</Loggers>
58+
59+
</Configuration>
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Configuration status="info">
3+
<Appenders>
4+
<Console name="Console-Appender" target="SYSTEM_OUT">
5+
<PatternLayout>
6+
<pattern>
7+
[%-5level] %d{HH:mm:ss.SSS} [%t] %c{1}.%M - %msg%n
8+
</pattern>>
9+
</PatternLayout>
10+
</Console>
11+
</Appenders>
12+
<Loggers>
13+
<Root level="info">
14+
<AppenderRef ref="Console-Appender"/>
15+
</Root>
16+
<Logger name="net.corda" level="info" additivity="false">
17+
<AppenderRef ref="Console-Appender"/>
18+
</Logger>
19+
</Loggers>
20+
</Configuration>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
cordaReleaseGroup=net.corda
2+
cordaCoreReleaseGroup=net.corda
3+
cordaVersion=4.4
4+
cordaCoreVersion=4.4
5+
gradlePluginsVersion=5.0.12
6+
kotlinVersion=1.2.71
7+
junitVersion=4.12
8+
quasarVersion=0.7.10
9+
log4jVersion =2.11.2
10+
platformVersion=5
11+
slf4jVersion=1.7.25
12+
nettyVersion=4.1.22.Final
13+

0 commit comments

Comments
 (0)