Skip to content

Commit

Permalink
Take LIGHTNING_DATA env variable in Dockerfile.
Browse files Browse the repository at this point in the history
Before this, docker image will never detects that
`lightning-rpc` was created if it is running in regtest
or testnet, because the file will be created under
subfolder for each network name, and entrypoint does not
check "lightning-rpc" file in those folders.
By specifying `LIGHTNINGD_NETWORK` environment var
in dockerfile, we can now check correct path.
  • Loading branch information
joemphilips committed Jul 6, 2020
1 parent 7981f4c commit 2cb94e2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends socat inotify-t
ENV LIGHTNINGD_DATA=/root/.lightning
ENV LIGHTNINGD_RPC_PORT=9835
ENV LIGHTNINGD_PORT=9735
ENV LIGHTNINGD_NETWORK=bitcoin

RUN mkdir $LIGHTNINGD_DATA && \
touch $LIGHTNINGD_DATA/config
Expand Down
10 changes: 6 additions & 4 deletions tools/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,20 @@

: "${EXPOSE_TCP:=false}"

networkdatadir="${LIGHTNINGD_DATA}/${LIGHTNINGD_NETWORK}"

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)
while read i; do if [ "$i" = "lightning-rpc" ]; then break; fi; done \
< <(inotifywait -e create,open --format '%f' --quiet "${networkdatadir}" --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" &
socat "TCP4-listen:$LIGHTNINGD_RPC_PORT,fork,reuseaddr" "UNIX-CONNECT:${networkdatadir}/lightning-rpc" &
fg %-
else
exec lightningd "$@"
exec lightningd --network="${LIGHTNINGD_NETWORK}" "$@"
fi

0 comments on commit 2cb94e2

Please sign in to comment.