mirror of
https://github.com/corda/corda.git
synced 2025-06-23 09:25:36 +00:00
Add Docker image as output of build (#4223)
This commit is contained in:
committed by
Michele Sollecito
parent
8827801ae6
commit
bbd5369e04
19
docker/src/bash/example-generate-testnet.sh
Executable file
19
docker/src/bash/example-generate-testnet.sh
Executable file
@ -0,0 +1,19 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
docker run -ti \
|
||||
-e MY_PUBLIC_ADDRESS="corda-node.example.com" \
|
||||
-e ONE_TIME_DOWNLOAD_KEY="bbcb189e-9e4f-4b27-96db-134e8f592785" \
|
||||
-e LOCALITY="London" -e COUNTRY="GB" \
|
||||
-v $(pwd)/docker/config:/etc/corda \
|
||||
-v $(pwd)/docker/certificates:/opt/corda/certificates \
|
||||
corda/corda-4.0-snapshot:latest config-generator --testnet
|
||||
|
||||
docker run -ti \
|
||||
--memory=2048m \
|
||||
--cpus=2 \
|
||||
-v $(pwd)/docker/config:/etc/corda \
|
||||
-v $(pwd)/docker/certificates:/opt/corda/certificates \
|
||||
-v $(pwd)/docker/persistence:/opt/corda/persistence \
|
||||
-v $(pwd)/docker/logs:/opt/corda/logs \
|
||||
-v $(pwd)/samples/bank-of-corda-demo/build/nodes/BankOfCorda/cordapps:/opt/corda/cordapps \
|
||||
corda/corda-4.0-snapshot:latest
|
27
docker/src/bash/example-join-generic-cz.sh
Executable file
27
docker/src/bash/example-join-generic-cz.sh
Executable file
@ -0,0 +1,27 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
##in this example the doorman will be running on the host machine on port 8080
|
||||
##so the container must be launched with "host" networking
|
||||
docker run -ti --net="host" \
|
||||
-e MY_LEGAL_NAME="O=EXAMPLE,L=Berlin,C=DE" \
|
||||
-e MY_PUBLIC_ADDRESS="corda.example-hoster.com" \
|
||||
-e NETWORKMAP_URL="https://map.corda.example.com" \
|
||||
-e DOORMAN_URL="https://doorman.corda.example.com" \
|
||||
-e NETWORK_TRUST_PASSWORD="trustPass" \
|
||||
-e MY_EMAIL_ADDRESS="cordauser@r3.com" \
|
||||
-v $(pwd)/docker/config:/etc/corda \
|
||||
-v $(pwd)/docker/certificates:/opt/corda/certificates \
|
||||
corda/corda-4.0-snapshot:latest config-generator --generic
|
||||
|
||||
##set memory to 2gb max, and 2cores max
|
||||
docker run -ti \
|
||||
--memory=2048m \
|
||||
--cpus=2 \
|
||||
-v $(pwd)/docker/config:/etc/corda \
|
||||
-v $(pwd)/docker/certificates:/opt/corda/certificates \
|
||||
-v $(pwd)/docker/persistence:/opt/corda/persistence \
|
||||
-v $(pwd)/docker/logs:/opt/corda/logs \
|
||||
-v $(pwd)/samples/bank-of-corda-demo/build/nodes/BankOfCorda/cordapps:/opt/corda/cordapps \
|
||||
-p 10200:10200 \
|
||||
-p 10201:10201 \
|
||||
corda/corda-4.0-snapshot:latest
|
124
docker/src/bash/generate-config.sh
Executable file
124
docker/src/bash/generate-config.sh
Executable file
@ -0,0 +1,124 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
|
||||
die() {
|
||||
printf '%s\n' "$1" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
show_help(){
|
||||
|
||||
echo "usage: generate-config <--testnet>|<--generic>"
|
||||
echo -e "\t --testnet is used to generate config and certificates for joining TestNet"
|
||||
echo -e "\t --generic is used to generate config and certificates for joining an existing Corda Compatibility Zone"
|
||||
|
||||
}
|
||||
|
||||
function generateTestnetConfig() {
|
||||
RPC_PASSWORD=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1) \
|
||||
DB_PASSWORD=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1) \
|
||||
MY_PUBLIC_ADDRESS=${MY_PUBLIC_ADDRESS} \
|
||||
MY_P2P_PORT=${MY_P2P_PORT} \
|
||||
MY_RPC_PORT=${MY_RPC_PORT} \
|
||||
MY_RPC_ADMIN_PORT=${MY_RPC_ADMIN_PORT} \
|
||||
NETWORKMAP_URL='https://map.testnet.corda.network' \
|
||||
DOORMAN_URL='https://doorman.testnet.corda.network' \
|
||||
java -jar config-exporter.jar "TEST-NET-COMBINE" "node.conf" "/opt/corda/starting-node.conf" "${CONFIG_FOLDER}/node.conf"
|
||||
}
|
||||
|
||||
function generateGenericCZConfig(){
|
||||
: ${NETWORKMAP_URL:? '$NETWORKMAP_URL, the Compatibility Zone to join must be set as environment variable'}
|
||||
: ${DOORMAN_URL:? '$DOORMAN_URL, the Doorman to use when joining must be set as environment variable'}
|
||||
: ${MY_LEGAL_NAME:? '$MY_LEGAL_NAME, the X500 name to use when joining must be set as environment variable'}
|
||||
: ${MY_EMAIL_ADDRESS:? '$MY_EMAIL_ADDRESS, the email to use when joining must be set as an environment variable'}
|
||||
: ${NETWORK_TRUST_PASSWORD=:? '$NETWORK_TRUST_PASSWORD, the password to the network store to use when joining must be set as environment variable'}
|
||||
|
||||
if [[ ! -f ${CERTIFICATES_FOLDER}/${TRUST_STORE_NAME} ]]; then
|
||||
die "Network Trust Root file not found"
|
||||
fi
|
||||
|
||||
RPC_PASSWORD=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1) \
|
||||
DB_PASSWORD=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1) \
|
||||
MY_PUBLIC_ADDRESS=${MY_PUBLIC_ADDRESS} \
|
||||
MY_P2P_PORT=${MY_P2P_PORT} \
|
||||
MY_RPC_PORT=${MY_RPC_PORT} \
|
||||
MY_RPC_ADMIN_PORT=${MY_RPC_ADMIN_PORT} \
|
||||
java -jar config-exporter.jar "GENERIC-CZ" "/opt/corda/starting-node.conf" "${CONFIG_FOLDER}/node.conf"
|
||||
|
||||
java -Djava.security.egd=file:/dev/./urandom -Dcapsule.jvm.args="${JVM_ARGS}" -jar /opt/corda/bin/corda.jar \
|
||||
initial-registration \
|
||||
--base-directory=/opt/corda \
|
||||
--config-file=/etc/corda/node.conf \
|
||||
--network-root-truststore-password=${NETWORK_TRUST_PASSWORD} \
|
||||
--network-root-truststore=${CERTIFICATES_FOLDER}/${TRUST_STORE_NAME}
|
||||
}
|
||||
|
||||
function downloadTestnetCerts() {
|
||||
if [[ ! -f ${CERTIFICATES_FOLDER}/certs.zip ]]; then
|
||||
: ${ONE_TIME_DOWNLOAD_KEY:? '$ONE_TIME_DOWNLOAD_KEY must be set as environment variable'}
|
||||
: ${LOCALITY:? '$LOCALITY (the locality used when registering for Testnet) must be set as environment variable'}
|
||||
: ${COUNTRY:? '$COUNTRY (the country used when registering for Testnet) must be set as environment variable'}
|
||||
curl -L -d "{\"x500Name\":{\"locality\":\"${LOCALITY}\", \"country\":\"${COUNTRY}\"}, \"configType\": \"INSTALLSCRIPT\", \"include\": { \"systemdServices\": false, \"cordapps\": false, \"cordaJar\": false, \"cordaWebserverJar\": false, \"scripts\": false} }" \
|
||||
-H 'Content-Type: application/json' \
|
||||
-X POST "https://testnet.corda.network/api/user/node/generate/one-time-key/redeem/$ONE_TIME_DOWNLOAD_KEY" \
|
||||
-o "${CERTIFICATES_FOLDER}/certs.zip"
|
||||
fi
|
||||
rm -rf ${CERTIFICATES_FOLDER}/*.jks
|
||||
unzip ${CERTIFICATES_FOLDER}/certs.zip
|
||||
}
|
||||
|
||||
GENERATE_TEST_NET=0
|
||||
GENERATE_GENERIC=0
|
||||
|
||||
while :; do
|
||||
case $1 in
|
||||
-h|-\?|--help)
|
||||
show_help # Display a usage synopsis.
|
||||
exit
|
||||
;;
|
||||
-t|--testnet)
|
||||
if [[ ${GENERATE_GENERIC} = 0 ]]; then
|
||||
GENERATE_TEST_NET=1
|
||||
else
|
||||
die 'ERROR: cannot generate config for multiple networks'
|
||||
fi
|
||||
;;
|
||||
-g|--generic)
|
||||
if [[ ${GENERATE_TEST_NET} = 0 ]]; then
|
||||
GENERATE_GENERIC=1
|
||||
else
|
||||
die 'ERROR: cannot generate config for multiple networks'
|
||||
fi
|
||||
;;
|
||||
--) # End of all options.
|
||||
shift
|
||||
break
|
||||
;;
|
||||
-?*)
|
||||
printf 'WARN: Unknown option (ignored): %s\n' "$1" >&2
|
||||
;;
|
||||
*) # Default case: No more options, so break out of the loop.
|
||||
break
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
|
||||
: ${TRUST_STORE_NAME="network-root-truststore.jks"}
|
||||
: ${JVM_ARGS='-Xmx4g -Xms2g -XX:+UseG1GC'}
|
||||
|
||||
|
||||
if [[ ${GENERATE_TEST_NET} == 1 ]]
|
||||
then
|
||||
: ${MY_PUBLIC_ADDRESS:? 'MY_PUBLIC_ADDRESS must be set as environment variable'}
|
||||
downloadTestnetCerts
|
||||
generateTestnetConfig
|
||||
elif [[ ${GENERATE_GENERIC} == 1 ]]
|
||||
then
|
||||
: ${MY_PUBLIC_ADDRESS:? 'MY_PUBLIC_ADDRESS must be set as environment variable'}
|
||||
generateGenericCZConfig
|
||||
else
|
||||
show_help
|
||||
die "No Valid Configuration requested"
|
||||
fi
|
||||
|
10
docker/src/bash/run-corda.sh
Executable file
10
docker/src/bash/run-corda.sh
Executable file
@ -0,0 +1,10 @@
|
||||
#!/usr/bin/env bash
|
||||
: ${JVM_ARGS='-XX:+UseG1GC'}
|
||||
|
||||
JVM_ARGS="-XX:+UnlockExperimentalVMOptions -XX:+UseCGroupMemoryLimitForHeap "${JVM_ARGS}
|
||||
|
||||
if [[ ${JVM_ARGS} == *"Xmx"* ]]; then
|
||||
echo "WARNING: the use of the -Xmx flag is not recommended within docker containers. Use the --memory option passed to the container to limit heap size"
|
||||
fi
|
||||
|
||||
java -Djava.security.egd=file:/dev/./urandom -Dcapsule.jvm.args="${JVM_ARGS}" -jar /opt/corda/bin/corda.jar --base-directory=/opt/corda --config-file=/etc/corda/node.conf
|
Reference in New Issue
Block a user