mirror of
https://github.com/corda/corda.git
synced 2025-01-18 02:39:51 +00:00
improve docker image and allow automatically restarting node after --initial-registration
This commit is contained in:
parent
7252c84a5a
commit
9581370a9c
@ -1,15 +1,15 @@
|
||||
#!/usr/bin/env bash
|
||||
NODE_LIST=("dockerNode1" "dockerNode2" "dockerNode3")
|
||||
NETWORK_NAME=mininet
|
||||
CORDAPP_VERSION="4.0-SNAPSHOT"
|
||||
DOCKER_IMAGE_VERSION="corda-zulu-4.0-rc02"
|
||||
CORDAPP_VERSION="5.0-SNAPSHOT"
|
||||
DOCKER_IMAGE_VERSION="corda-zulu-5.0-snapshot"
|
||||
|
||||
mkdir cordapps
|
||||
rm -f cordapps/*
|
||||
|
||||
wget -O cordapps/finance-contracts.jar https://ci-artifactory.corda.r3cev.com/artifactory/list/corda-dev/net/corda/corda-finance-contracts/${CORDAPP_VERSION}/corda-finance-contracts-4.0-SNAPSHOT.jar
|
||||
wget -O cordapps/finance-workflows.jar https://ci-artifactory.corda.r3cev.com/artifactory/list/corda-dev/net/corda/corda-finance-workflows/${CORDAPP_VERSION}/corda-finance-workflows-4.0-SNAPSHOT.jar
|
||||
wget -O cordapps/confidential-identities.jar https://ci-artifactory.corda.r3cev.com/artifactory/list/corda-dev/net/corda/corda-confidential-identities/${CORDAPP_VERSION}/corda-confidential-identities-4.0-SNAPSHOT.jar
|
||||
wget -O cordapps/finance-contracts.jar https://ci-artifactory.corda.r3cev.com/artifactory/list/corda-dev/net/corda/corda-finance-contracts/${CORDAPP_VERSION}/corda-finance-contracts-${CORDAPP_VERSION}.jar
|
||||
wget -O cordapps/finance-workflows.jar https://ci-artifactory.corda.r3cev.com/artifactory/list/corda-dev/net/corda/corda-finance-workflows/${CORDAPP_VERSION}/corda-finance-workflows-${CORDAPP_VERSION}.jar
|
||||
wget -O cordapps/confidential-identities.jar https://ci-artifactory.corda.r3cev.com/artifactory/list/corda-dev/net/corda/corda-confidential-identities/${CORDAPP_VERSION}/corda-confidential-identities-${CORDAPP_VERSION}.jar
|
||||
|
||||
rm keystore
|
||||
|
||||
@ -36,11 +36,10 @@ do
|
||||
mkdir ${NODE}/certificates
|
||||
mkdir ${NODE}/logs
|
||||
mkdir ${NODE}/persistence
|
||||
|
||||
done
|
||||
|
||||
docker rm -f netmap
|
||||
docker network rm ${NETWORK_NAME}
|
||||
docker network rm -f ${NETWORK_NAME}
|
||||
|
||||
docker network create --attachable ${NETWORK_NAME}
|
||||
docker run -d \
|
||||
@ -56,7 +55,7 @@ while [ ${EXIT_CODE} -gt 0 ]
|
||||
do
|
||||
sleep 2
|
||||
echo "Waiting for network map to start"
|
||||
curl -s http://localhost:18080/network-map > /dev/null
|
||||
curl --max-time 2 -s http://localhost:18080/network-map > /dev/null
|
||||
let EXIT_CODE=$?
|
||||
done
|
||||
|
||||
@ -64,7 +63,7 @@ for NODE in ${NODE_LIST[*]}
|
||||
do
|
||||
wget -O ${NODE}/certificates/network-root-truststore.jks http://localhost:18080/truststore
|
||||
docker rm -f ${NODE}
|
||||
docker run \
|
||||
docker run -d \
|
||||
-e MY_LEGAL_NAME="O=${NODE},L=Berlin,C=DE" \
|
||||
-e MY_PUBLIC_ADDRESS="${NODE}" \
|
||||
-e NETWORKMAP_URL="http://netmap:8080" \
|
||||
@ -76,17 +75,6 @@ do
|
||||
-v $(pwd)/${NODE}/config:/etc/corda \
|
||||
-v $(pwd)/${NODE}/certificates:/opt/corda/certificates \
|
||||
-v $(pwd)/${NODE}/logs:/opt/corda/logs \
|
||||
--name ${NODE} \
|
||||
--network="${NETWORK_NAME}" \
|
||||
corda/${DOCKER_IMAGE_VERSION}:latest config-generator --generic
|
||||
|
||||
docker rm -f ${NODE}
|
||||
docker run -d \
|
||||
--memory=2048m \
|
||||
--cpus=2 \
|
||||
-v $(pwd)/${NODE}/config:/etc/corda \
|
||||
-v $(pwd)/${NODE}/certificates:/opt/corda/certificates \
|
||||
-v $(pwd)/${NODE}/logs:/opt/corda/logs \
|
||||
-v $(pwd)/${NODE}/persistence:/opt/corda/persistence \
|
||||
-v $(pwd)/cordapps:/opt/corda/cordapps \
|
||||
-p "1100"$(echo ${NODE} | sed 's/[^0-9]*//g'):"1100"$(echo ${NODE} | sed 's/[^0-9]*//g') \
|
||||
@ -94,5 +82,5 @@ do
|
||||
-e CORDA_ARGS="--sshd --sshd-port=222$(echo ${NODE} | sed 's/[^0-9]*//g')" \
|
||||
--name ${NODE} \
|
||||
--network="${NETWORK_NAME}" \
|
||||
corda/${DOCKER_IMAGE_VERSION}:latest
|
||||
corda/${DOCKER_IMAGE_VERSION}:latest config-generator --generic
|
||||
done
|
@ -6,11 +6,9 @@ die() {
|
||||
}
|
||||
|
||||
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() {
|
||||
@ -27,30 +25,38 @@ function generateTestnetConfig() {
|
||||
}
|
||||
|
||||
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"
|
||||
if [[ -f /etc/corda/node.conf ]] ; then
|
||||
echo 'WARN: existing config detected, launching corda'
|
||||
run-corda
|
||||
else
|
||||
: ${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)}
|
||||
RPC_PASSWORD=${RPC_PASSWORD} \
|
||||
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} &&\
|
||||
echo "Succesfully registered with ${DOORMAN_URL}, starting corda" && \
|
||||
run-corda
|
||||
fi
|
||||
: ${RPC_PASSWORD=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)}
|
||||
RPC_PASSWORD=${RPC_PASSWORD} \
|
||||
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() {
|
||||
|
Loading…
Reference in New Issue
Block a user