Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion contrib/compose/.env
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
NETWORK=testnet
NETWORK=groestlcoin
LIGHTNING_ALIAS=
HOST=127.0.0.1
SPARK_LOGIN=admin:admin
Expand Down
3 changes: 2 additions & 1 deletion contrib/compose/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

12 changes: 7 additions & 5 deletions contrib/compose/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: "3"
version: "3.4"
services:
groestlcoind:
restart: unless-stopped
Expand All @@ -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
Expand All @@ -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:
Expand All @@ -53,4 +54,5 @@ services:
- "clightning_groestlcoin_datadir:/etc/lightning"

volumes:
clightning_groestlcoin_datadir:
clightning_groestlcoin_datadir:
groestlcoin_datadir:
40 changes: 36 additions & 4 deletions tools/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,63 @@

: "${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"
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
Expand Down