Browse Source

Take LIGHTNINGD_NETWORK env variable in Dockerfile.

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`.
paymod-03
joe.miyamoto 5 years ago
committed by Christian Decker
parent
commit
0b1f8fdbf0
  1. 1
      Dockerfile
  2. 8
      tools/docker-entrypoint.sh

1
Dockerfile

@ -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

8
tools/docker-entrypoint.sh

@ -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

Loading…
Cancel
Save