Skip to content

Commit

Permalink
Merge pull request #15 from Kukks/feat/final-push
Browse files Browse the repository at this point in the history
fix docker related components on upstream
  • Loading branch information
gruve-p authored Dec 20, 2018
2 parents cebb82c + 5e4ae34 commit a1d490c
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 33 deletions.
23 changes: 4 additions & 19 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ RUN mkdir /opt/groestlcoin && cd /opt/groestlcoin \
&& echo "$GROESTLCOIN_SHA256 groestlcoin.tar.gz" | sha256sum -c - \
&& tar -xzvf groestlcoin.tar.gz groestlcoin-cli --exclude=*-qt \
&& rm groestlcoin.tar.gz

ENV LIGHTNINGD_VERSION=master

WORKDIR /opt/lightningd
Expand All @@ -24,26 +24,12 @@ 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

Expand All @@ -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
Expand Down
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: groestlcoin/lightning:v0.6.2-1
build:
context: ../..
stop_signal: SIGKILL
container_name: clightning_groestlcoin
restart: unless-stopped
Expand All @@ -33,13 +34,13 @@ services:
alias=${LIGHTNING_ALIAS}
volumes:
- "clightning_groestlcoin_datadir:/root/.lightning"
- "./groestlcoin_datadir:/etc/groestlcoin"
- "groestlcoin_datadir:/etc/groestlcoin"
ports:
- "9735:9735"
links:
- groestlcoind
clightning_groestlcoin_spark:
image: groestlcoin/spark-wallet:v0.2.1
image: groestlcoin/spark-wallet:v0.2.1-1
container_name: clightning_groestlcoin_spark
restart: unless-stopped
environment:
Expand All @@ -54,3 +55,4 @@ services:

volumes:
clightning_groestlcoin_datadir:
groestlcoin_datadir:
43 changes: 34 additions & 9 deletions tools/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +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

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
Expand Down

0 comments on commit a1d490c

Please sign in to comment.