diff --git a/Dockerfile b/Dockerfile index 66263f60d3b4..5da0da4abd5e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -24,11 +24,11 @@ COPY . . ARG DEVELOPER=0 RUN ./configure && make -j3 DEVELOPER=${DEVELOPER} && cp lightningd/lightning* cli/lightning-cli /usr/bin/ -FROM debian: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 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..570294d45969 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 mainnet 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..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: kukks/grs-clightning:latest + 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: @@ -53,4 +54,5 @@ services: - "clightning_groestlcoin_datadir:/etc/lightning" volumes: - clightning_groestlcoin_datadir: \ No newline at end of file + clightning_groestlcoin_datadir: + groestlcoin_datadir: diff --git a/tools/docker-entrypoint.sh b/tools/docker-entrypoint.sh index bebb7d10512c..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,16 +19,46 @@ if [[ $REPLACEDNETWORK ]]; then 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