From 1a274b1b6f22a422cd2b89ef7c1b074608bae984 Mon Sep 17 00:00:00 2001 From: Kukks Date: Tue, 11 Dec 2018 16:34:00 +0100 Subject: [PATCH 1/6] test out nodewaiter --- Dockerfile | 17 ++++++++++++++++- contrib/compose/.env | 2 +- contrib/compose/README.md | 3 ++- contrib/compose/docker-compose.yml | 2 +- tools/docker-entrypoint.sh | 7 +++++++ 5 files changed, 27 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 66263f60d3b4..b13b2f5b1494 100644 --- a/Dockerfile +++ b/Dockerfile @@ -24,7 +24,21 @@ COPY . . ARG DEVELOPER=0 RUN ./configure && make -j3 DEVELOPER=${DEVELOPER} && cp lightningd/lightning* cli/lightning-cli /usr/bin/ -FROM debian:stretch-slim + +FROM microsoft/dotnet:2.1.403-sdk-alpine3.7 AS dotnetbuilder + +RUN apk add --no-cache git + +WORKDIR /source + +RUN git clone https://github.com/dgarage/NBXplorer && cd NBXplorer && git checkout 88a8db8be3911f59b4b6109845b547368c5f02fb + +# Cache some dependencies +RUN cd NBXplorer/NBXplorer.NodeWaiter && dotnet restore && cd .. +RUN cd NBXplorer/NBXplorer.NodeWaiter && \ + dotnet publish --output /app/ --configuration Release + +FROM microsoft/dotnet:2.2-runtime-deps-stretch-slim RUN apt-get update && apt-get install -y \ autoconf automake build-essential git libtool libgmp-dev \ @@ -41,6 +55,7 @@ VOLUME [ "/root/.lightning" ] COPY --from=builder /opt/lightningd/cli/lightning-cli /usr/bin COPY --from=builder /opt/lightningd/lightningd/lightning* /usr/bin/ COPY --from=builder /opt/groestlcoin /usr/bin +COPY --from=dotnetbuilder /app /opt/NBXplorer.NodeWaiter COPY tools/docker-entrypoint.sh entrypoint.sh EXPOSE 9735 9835 diff --git a/contrib/compose/.env b/contrib/compose/.env index b77f27b8dccc..38b7e775d6b4 100644 --- a/contrib/compose/.env +++ b/contrib/compose/.env @@ -1,4 +1,4 @@ -NETWORK=testnet +NETWORK=groestlcoin LIGHTNING_ALIAS= HOST=127.0.0.1 SPARK_LOGIN=admin:admin diff --git a/contrib/compose/README.md b/contrib/compose/README.md index ab5778a964a5..1c8ca19dad4a 100644 --- a/contrib/compose/README.md +++ b/contrib/compose/README.md @@ -4,4 +4,5 @@ This is an example of how to run a GRS node, GRS c-lightning node and Spark wall ### Configuration & Running -Ensure you have docker & docker-compose installed, edit the `.env` options to your liking and run `docker-compose up`. By default it will run testnet and spark wallet wil lbe available at `localhost:9876` (after GRS syncs) +Ensure you have docker & docker-compose installed, edit the `.env` options to your liking and run `docker-compose up`. By default it will run testnet and spark wallet will be available at `localhost:9876` (after GRS syncs) + diff --git a/contrib/compose/docker-compose.yml b/contrib/compose/docker-compose.yml index 32839f4a198f..0148f22321a1 100644 --- a/contrib/compose/docker-compose.yml +++ b/contrib/compose/docker-compose.yml @@ -16,7 +16,7 @@ services: volumes: - "./groestlcoin_datadir:/data" clightning_groestlcoin: - image: kukks/grs-clightning:latest + image: groestlcoin/lightning:v0.6.2 stop_signal: SIGKILL container_name: clightning_groestlcoin restart: unless-stopped diff --git a/tools/docker-entrypoint.sh b/tools/docker-entrypoint.sh index bebb7d10512c..00139c501592 100755 --- a/tools/docker-entrypoint.sh +++ b/tools/docker-entrypoint.sh @@ -17,6 +17,13 @@ if [[ $REPLACEDNETWORK ]]; then echo "Replaced network $NETWORK by $REPLACEDNETWORK in $LIGHTNINGD_DATA/config" fi +if [[ $LIGHTNINGD_EXPLORERURL && $NETWORK ]]; then + # We need to do that because clightning behave weird if it starts at same time as bitcoin core, or if the node is not synched + echo "Waiting for the node to start and sync" + dotnet /opt/NBXplorer.NodeWaiter/NBXplorer.NodeWaiter.dll --chains "grs" --network "$NETWORK" --explorerurl "$LIGHTNINGD_EXPLORERURL" + echo "Node synched" +fi + if [ "$EXPOSE_TCP" == "true" ]; then set -m lightningd "$@" & From 73ee152771ceee58cb05a6b8c6b58de8aaea0c6e Mon Sep 17 00:00:00 2001 From: Kukks Date: Tue, 11 Dec 2018 17:44:25 +0100 Subject: [PATCH 2/6] update readme --- contrib/compose/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/compose/README.md b/contrib/compose/README.md index 1c8ca19dad4a..570294d45969 100644 --- a/contrib/compose/README.md +++ b/contrib/compose/README.md @@ -4,5 +4,5 @@ This is an example of how to run a GRS node, GRS c-lightning node and Spark wall ### Configuration & Running -Ensure you have docker & docker-compose installed, edit the `.env` options to your liking and run `docker-compose up`. By default it will run testnet and spark wallet will be available at `localhost:9876` (after GRS syncs) +Ensure you have docker & docker-compose installed, edit the `.env` options to your liking and run `docker-compose up`. By default it will run mainnet and spark wallet will be available at `localhost:9876` (after GRS syncs) From b3dc06bd1eca3ffe542e9c45137ca289bd618ed5 Mon Sep 17 00:00:00 2001 From: Kukks Date: Tue, 11 Dec 2018 18:45:48 +0100 Subject: [PATCH 3/6] fix var --- tools/docker-entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/docker-entrypoint.sh b/tools/docker-entrypoint.sh index 00139c501592..8e74f936e648 100755 --- a/tools/docker-entrypoint.sh +++ b/tools/docker-entrypoint.sh @@ -17,7 +17,7 @@ if [[ $REPLACEDNETWORK ]]; then echo "Replaced network $NETWORK by $REPLACEDNETWORK in $LIGHTNINGD_DATA/config" fi -if [[ $LIGHTNINGD_EXPLORERURL && $NETWORK ]]; then +if [[ $LIGHTNINGD_EXPLORERURL && $LIGHTNINGD_NETWORK ]]; then # We need to do that because clightning behave weird if it starts at same time as bitcoin core, or if the node is not synched echo "Waiting for the node to start and sync" dotnet /opt/NBXplorer.NodeWaiter/NBXplorer.NodeWaiter.dll --chains "grs" --network "$NETWORK" --explorerurl "$LIGHTNINGD_EXPLORERURL" From aadf8eb8bd1b6f1855f5b25afb8143c191c59630 Mon Sep 17 00:00:00 2001 From: Andrew Camilleri Date: Tue, 11 Dec 2018 21:09:21 +0100 Subject: [PATCH 4/6] Update docker-compose.yml --- contrib/compose/docker-compose.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/contrib/compose/docker-compose.yml b/contrib/compose/docker-compose.yml index 0148f22321a1..788c22d1326d 100644 --- a/contrib/compose/docker-compose.yml +++ b/contrib/compose/docker-compose.yml @@ -16,7 +16,7 @@ services: volumes: - "./groestlcoin_datadir:/data" clightning_groestlcoin: - image: groestlcoin/lightning:v0.6.2 + image: groestlcoin/lightning:v0.6.2-1 stop_signal: SIGKILL container_name: clightning_groestlcoin restart: unless-stopped @@ -53,4 +53,4 @@ services: - "clightning_groestlcoin_datadir:/etc/lightning" volumes: - clightning_groestlcoin_datadir: \ No newline at end of file + clightning_groestlcoin_datadir: From accb0c961251c5868024853586e19ebea6867815 Mon Sep 17 00:00:00 2001 From: Andrew Camilleri Date: Wed, 12 Dec 2018 16:35:37 +0100 Subject: [PATCH 5/6] remove nbxplorer dependency --- Dockerfile | 19 +------ contrib/compose/docker-compose.yml | 10 ++-- contrib/compose/test/docker-entrypoint.sh | 66 +++++++++++++++++++++++ tools/docker-entrypoint.sh | 43 +++++++++++---- 4 files changed, 108 insertions(+), 30 deletions(-) create mode 100644 contrib/compose/test/docker-entrypoint.sh diff --git a/Dockerfile b/Dockerfile index b13b2f5b1494..5da0da4abd5e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -24,25 +24,11 @@ COPY . . ARG DEVELOPER=0 RUN ./configure && make -j3 DEVELOPER=${DEVELOPER} && cp lightningd/lightning* cli/lightning-cli /usr/bin/ - -FROM microsoft/dotnet:2.1.403-sdk-alpine3.7 AS dotnetbuilder - -RUN apk add --no-cache git - -WORKDIR /source - -RUN git clone https://github.com/dgarage/NBXplorer && cd NBXplorer && git checkout 88a8db8be3911f59b4b6109845b547368c5f02fb - -# Cache some dependencies -RUN cd NBXplorer/NBXplorer.NodeWaiter && dotnet restore && cd .. -RUN cd NBXplorer/NBXplorer.NodeWaiter && \ - dotnet publish --output /app/ --configuration Release - -FROM microsoft/dotnet:2.2-runtime-deps-stretch-slim +FROM debian:stretch-slim RUN apt-get update && apt-get install -y \ autoconf automake build-essential git libtool libgmp-dev \ - libsqlite3-dev python python3 net-tools zlib1g-dev + libsqlite3-dev python python3 net-tools zlib1g-dev jq bc ENV LIGHTNINGD_DATA=/root/.lightning ENV LIGHTNINGD_RPC_PORT=9835 @@ -55,7 +41,6 @@ VOLUME [ "/root/.lightning" ] COPY --from=builder /opt/lightningd/cli/lightning-cli /usr/bin COPY --from=builder /opt/lightningd/lightningd/lightning* /usr/bin/ COPY --from=builder /opt/groestlcoin /usr/bin -COPY --from=dotnetbuilder /app /opt/NBXplorer.NodeWaiter COPY tools/docker-entrypoint.sh entrypoint.sh EXPOSE 9735 9835 diff --git a/contrib/compose/docker-compose.yml b/contrib/compose/docker-compose.yml index 788c22d1326d..ec9b7e035dc5 100644 --- a/contrib/compose/docker-compose.yml +++ b/contrib/compose/docker-compose.yml @@ -1,4 +1,4 @@ -version: "3" +version: "3.4" services: groestlcoind: restart: unless-stopped @@ -14,9 +14,10 @@ services: - "43782" - "39388" volumes: - - "./groestlcoin_datadir:/data" + - "groestlcoin_datadir:/data" clightning_groestlcoin: - image: groestlcoin/lightning:v0.6.2-1 + build: + context: ../.. stop_signal: SIGKILL container_name: clightning_groestlcoin restart: unless-stopped @@ -33,7 +34,7 @@ services: alias=${LIGHTNING_ALIAS} volumes: - "clightning_groestlcoin_datadir:/root/.lightning" - - "./groestlcoin_datadir:/etc/groestlcoin" + - "groestlcoin_datadir:/etc/groestlcoin" ports: - "9735:9735" links: @@ -54,3 +55,4 @@ services: volumes: clightning_groestlcoin_datadir: + groestlcoin_datadir: diff --git a/contrib/compose/test/docker-entrypoint.sh b/contrib/compose/test/docker-entrypoint.sh new file mode 100644 index 000000000000..aac90038582f --- /dev/null +++ b/contrib/compose/test/docker-entrypoint.sh @@ -0,0 +1,66 @@ +#!/usr/bin/env bash + +: "${EXPOSE_TCP:=false}" + +if [[ $LIGHTNINGD_OPT ]]; then + cat <<-EOF > "$LIGHTNINGD_DATA/config" +${LIGHTNINGD_OPT} +EOF +fi + +NETWORK=$(sed -n 's/^network=\(.*\)$/\1/p' < "$LIGHTNINGD_DATA/config") +REPLACEDNETWORK=""; +if [ "$NETWORK" == "mainnet" ]; then + REPLACEDNETWORK="groestlcoin" +fi +if [[ $REPLACEDNETWORK ]]; then + sed -i '/^network=/d' "$LIGHTNINGD_DATA/config" + echo "network=$REPLACEDNETWORK" >> "$LIGHTNINGD_DATA/config" + echo "Replaced network $NETWORK by $REPLACEDNETWORK in $LIGHTNINGD_DATA/config" +fi + + +wait_sync () { + rpcConnect=$(sed -n 's/^bitcoin-rpcconnect=\(.*\)$/\1/p' < "$LIGHTNINGD_DATA/config") + dataDir=$(sed -n 's/^bitcoin-datadir=\(.*\)$/\1/p' < "$LIGHTNINGD_DATA/config") + rpcPort=$(sed -n 's/^bitcoin-rpcport=\(.*\)$/\1/p' < "$LIGHTNINGD_DATA/config") + + status=$(groestlcoin-cli -datadir="$dataDir" -rpcport="$rpcPort" -rpcconnect="$rpcConnect" echo ok) + status=$(echo "$status" | jq '.[0]') + expectedstatus="\"ok\"" + if [[ "$status" != "$expectedstatus" ]]; then + echo "Could not connect to node: $status" + sleep 5 + wait_sync; + return + fi + result=$(groestlcoin-cli -datadir="$dataDir" -rpcport="$rpcPort" -rpcconnect="$rpcConnect" getblockchaininfo) + isDownload=$(echo "$result" | jq '.initialblockdownload') + progress=$(echo "$result" | jq '.verificationprogress') + if [[ $isDownload == true ]] || [[ $(echo "$progress < 0.99" |bc -l) -eq 1 ]]; then + echo "Waiting for the node to sync($progress %)" + sleep 5 + wait_sync; + return; + fi + echo "Node synched" +} + +wait_sync + + +if [ "$EXPOSE_TCP" == "true" ]; then + set -m + lightningd "$@" & + + echo "C-Lightning starting" + while read -r i; do if [ "$i" = "lightning-rpc" ]; then break; fi; done \ + < <(inotifywait -e create,open --format '%f' --quiet "$LIGHTNINGD_DATA" --monitor) + echo "C-Lightning started" + echo "C-Lightning started, RPC available on port $LIGHTNINGD_RPC_PORT" + + socat "TCP4-listen:$LIGHTNINGD_RPC_PORT,fork,reuseaddr" "UNIX-CONNECT:$LIGHTNINGD_DATA/lightning-rpc" & + fg %- +else + lightningd "$@" +fi diff --git a/tools/docker-entrypoint.sh b/tools/docker-entrypoint.sh index 8e74f936e648..aac90038582f 100755 --- a/tools/docker-entrypoint.sh +++ b/tools/docker-entrypoint.sh @@ -2,14 +2,16 @@ : "${EXPOSE_TCP:=false}" -cat <<-EOF > "$LIGHTNINGD_DATA/config" +if [[ $LIGHTNINGD_OPT ]]; then + cat <<-EOF > "$LIGHTNINGD_DATA/config" ${LIGHTNINGD_OPT} EOF +fi NETWORK=$(sed -n 's/^network=\(.*\)$/\1/p' < "$LIGHTNINGD_DATA/config") REPLACEDNETWORK=""; if [ "$NETWORK" == "mainnet" ]; then - REPLACEDNETWORK="groestlcoin" + REPLACEDNETWORK="groestlcoin" fi if [[ $REPLACEDNETWORK ]]; then sed -i '/^network=/d' "$LIGHTNINGD_DATA/config" @@ -17,23 +19,46 @@ if [[ $REPLACEDNETWORK ]]; then echo "Replaced network $NETWORK by $REPLACEDNETWORK in $LIGHTNINGD_DATA/config" fi -if [[ $LIGHTNINGD_EXPLORERURL && $LIGHTNINGD_NETWORK ]]; then - # We need to do that because clightning behave weird if it starts at same time as bitcoin core, or if the node is not synched - echo "Waiting for the node to start and sync" - dotnet /opt/NBXplorer.NodeWaiter/NBXplorer.NodeWaiter.dll --chains "grs" --network "$NETWORK" --explorerurl "$LIGHTNINGD_EXPLORERURL" + +wait_sync () { + rpcConnect=$(sed -n 's/^bitcoin-rpcconnect=\(.*\)$/\1/p' < "$LIGHTNINGD_DATA/config") + dataDir=$(sed -n 's/^bitcoin-datadir=\(.*\)$/\1/p' < "$LIGHTNINGD_DATA/config") + rpcPort=$(sed -n 's/^bitcoin-rpcport=\(.*\)$/\1/p' < "$LIGHTNINGD_DATA/config") + + status=$(groestlcoin-cli -datadir="$dataDir" -rpcport="$rpcPort" -rpcconnect="$rpcConnect" echo ok) + status=$(echo "$status" | jq '.[0]') + expectedstatus="\"ok\"" + if [[ "$status" != "$expectedstatus" ]]; then + echo "Could not connect to node: $status" + sleep 5 + wait_sync; + return + fi + result=$(groestlcoin-cli -datadir="$dataDir" -rpcport="$rpcPort" -rpcconnect="$rpcConnect" getblockchaininfo) + isDownload=$(echo "$result" | jq '.initialblockdownload') + progress=$(echo "$result" | jq '.verificationprogress') + if [[ $isDownload == true ]] || [[ $(echo "$progress < 0.99" |bc -l) -eq 1 ]]; then + echo "Waiting for the node to sync($progress %)" + sleep 5 + wait_sync; + return; + fi echo "Node synched" -fi +} + +wait_sync + if [ "$EXPOSE_TCP" == "true" ]; then set -m lightningd "$@" & - + echo "C-Lightning starting" while read -r i; do if [ "$i" = "lightning-rpc" ]; then break; fi; done \ < <(inotifywait -e create,open --format '%f' --quiet "$LIGHTNINGD_DATA" --monitor) echo "C-Lightning started" echo "C-Lightning started, RPC available on port $LIGHTNINGD_RPC_PORT" - + socat "TCP4-listen:$LIGHTNINGD_RPC_PORT,fork,reuseaddr" "UNIX-CONNECT:$LIGHTNINGD_DATA/lightning-rpc" & fg %- else From 043b65eb87f2facb5c079ffa27fcbb05de2ca122 Mon Sep 17 00:00:00 2001 From: Andrew Camilleri Date: Thu, 13 Dec 2018 16:03:29 +0100 Subject: [PATCH 6/6] remove test --- contrib/compose/test/docker-entrypoint.sh | 66 ----------------------- 1 file changed, 66 deletions(-) delete mode 100644 contrib/compose/test/docker-entrypoint.sh diff --git a/contrib/compose/test/docker-entrypoint.sh b/contrib/compose/test/docker-entrypoint.sh deleted file mode 100644 index aac90038582f..000000000000 --- a/contrib/compose/test/docker-entrypoint.sh +++ /dev/null @@ -1,66 +0,0 @@ -#!/usr/bin/env bash - -: "${EXPOSE_TCP:=false}" - -if [[ $LIGHTNINGD_OPT ]]; then - cat <<-EOF > "$LIGHTNINGD_DATA/config" -${LIGHTNINGD_OPT} -EOF -fi - -NETWORK=$(sed -n 's/^network=\(.*\)$/\1/p' < "$LIGHTNINGD_DATA/config") -REPLACEDNETWORK=""; -if [ "$NETWORK" == "mainnet" ]; then - REPLACEDNETWORK="groestlcoin" -fi -if [[ $REPLACEDNETWORK ]]; then - sed -i '/^network=/d' "$LIGHTNINGD_DATA/config" - echo "network=$REPLACEDNETWORK" >> "$LIGHTNINGD_DATA/config" - echo "Replaced network $NETWORK by $REPLACEDNETWORK in $LIGHTNINGD_DATA/config" -fi - - -wait_sync () { - rpcConnect=$(sed -n 's/^bitcoin-rpcconnect=\(.*\)$/\1/p' < "$LIGHTNINGD_DATA/config") - dataDir=$(sed -n 's/^bitcoin-datadir=\(.*\)$/\1/p' < "$LIGHTNINGD_DATA/config") - rpcPort=$(sed -n 's/^bitcoin-rpcport=\(.*\)$/\1/p' < "$LIGHTNINGD_DATA/config") - - status=$(groestlcoin-cli -datadir="$dataDir" -rpcport="$rpcPort" -rpcconnect="$rpcConnect" echo ok) - status=$(echo "$status" | jq '.[0]') - expectedstatus="\"ok\"" - if [[ "$status" != "$expectedstatus" ]]; then - echo "Could not connect to node: $status" - sleep 5 - wait_sync; - return - fi - result=$(groestlcoin-cli -datadir="$dataDir" -rpcport="$rpcPort" -rpcconnect="$rpcConnect" getblockchaininfo) - isDownload=$(echo "$result" | jq '.initialblockdownload') - progress=$(echo "$result" | jq '.verificationprogress') - if [[ $isDownload == true ]] || [[ $(echo "$progress < 0.99" |bc -l) -eq 1 ]]; then - echo "Waiting for the node to sync($progress %)" - sleep 5 - wait_sync; - return; - fi - echo "Node synched" -} - -wait_sync - - -if [ "$EXPOSE_TCP" == "true" ]; then - set -m - lightningd "$@" & - - echo "C-Lightning starting" - while read -r i; do if [ "$i" = "lightning-rpc" ]; then break; fi; done \ - < <(inotifywait -e create,open --format '%f' --quiet "$LIGHTNINGD_DATA" --monitor) - echo "C-Lightning started" - echo "C-Lightning started, RPC available on port $LIGHTNINGD_RPC_PORT" - - socat "TCP4-listen:$LIGHTNINGD_RPC_PORT,fork,reuseaddr" "UNIX-CONNECT:$LIGHTNINGD_DATA/lightning-rpc" & - fg %- -else - lightningd "$@" -fi