Skip to content

Commit

Permalink
Take LIGHTNINGD_NETWORK 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.

Changelog-Added: Docker build now includes `LIGHTNINGD_NETWORK` ENV variable which defaults to "bitcoin". An user can override this (e.g. by `-e` option in `docker run`) to run docker container in regtest or testnet or any valid argument to `--network`.
  • Loading branch information
joemphilips authored and cdecker committed Jul 7, 2020
1 parent 3fec96a commit 0b1f8fd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 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
8 changes: 5 additions & 3 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)
< <(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 0b1f8fd

Please sign in to comment.