From 8767df010546413b9d61bebaeff1de35fc206c12 Mon Sep 17 00:00:00 2001 From: BT Date: Fri, 20 Nov 2020 16:12:45 +0000 Subject: [PATCH] Acktuallly... no need to put this in the build stage.. should be in the final. Python is already there ;) --- Dockerfile | 41 ++++++++++++++++++++++++------------ README.md | 24 ++++++++++++++++++++- doc/config.dist | 14 +++++++++++- scripts/docker-entrypoint.sh | 26 +++++++++++++++++++++++ 4 files changed, 89 insertions(+), 16 deletions(-) create mode 100755 scripts/docker-entrypoint.sh diff --git a/Dockerfile b/Dockerfile index c2b21ea..cd28179 100644 --- a/Dockerfile +++ b/Dockerfile @@ -39,19 +39,20 @@ ARG VERSION ARG REPO RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates autoconf automake build-essential git libtool python3 python3-mako wget gnupg dirmngr git gettext libgmp-dev libsqlite3-dev net-tools zlib1g-dev unzip tclsh git +ARG DEVELOPER=0 WORKDIR /opt -RUN git clone $REPO -WORKDIR /opt/lightning -RUN ls -la -RUN mkdir -p /tmp/lightning_install - -RUN git checkout $VERSION -#RUN git clone --recursive /tmp/lightning . && \ -# git checkout $(git --work-tree=/tmp/lightning --git-dir=/tmp/lightning/.git rev-parse HEAD) - -ARG DEVELOPER=0 -RUN ./configure --prefix=/tmp/lightning_install --enable-static && make -j3 DEVELOPER=${DEVELOPER} && make install +RUN git clone $REPO && \ + cd lightning && \ + ls -la && \ + mkdir -p /tmp/lightning_install && \ + ls -la /tmp && \ + git checkout $VERSION && \ + ./configure --prefix=/tmp/lightning_install \ + --enable-static && \ + make -j3 DEVELOPER=${DEVELOPER} && \ + make install && \ + ls -la /tmp/lightning_install FROM debian:buster-slim as final ARG USER @@ -59,22 +60,34 @@ ARG DATA LABEL maintainer="nolim1t (hello@nolim1t.co)" -RUN apt-get update && apt-get install -y --no-install-recommends socat inotify-tools python3 python3-pip \ +RUN apt-get update && apt-get install -y --no-install-recommends git socat inotify-tools python3 python3-pip cargo \ && rm -rf /var/lib/apt/lists/* COPY --from=builder /lib /lib COPY --from=builder /tmp/lightning_install/ /usr/local/ COPY --from=downloader /opt/bin /usr/bin -COPY --from=builder /opt/lightning/tools/docker-entrypoint.sh entrypoint.sh +COPY ./scripts/docker-entrypoint.sh entrypoint.sh + +RUN mkdir /rust-plugin && \ + chown 1000.1000 /rust-plugin RUN adduser --disabled-password \ --home "$DATA" \ --gecos "" \ "$USER" - USER $USER +# Build and install http rust plugin to the following dir +# /rust-plugin/c-lightning-http-plugin/target/release/c-lightning-http-plugin +RUN cd /rust-plugin && \ + git clone https://github.com/Start9Labs/c-lightning-http-plugin.git && \ + cd c-lightning-http-plugin && \ + cargo build --release && \ + ls -la target/release/c-lightning-http-plugin && \ + pwd + + ENV LIGHTNINGD_DATA=$DATA/.lightning ENV LIGHTNINGD_RPC_PORT=9835 ENV LIGHTNINGD_PORT=9735 diff --git a/README.md b/README.md index 4e8d3c0..956c0b5 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,8 @@ [C-Lightning](https://github.com/ElementsProject/lightning) by [Elements Project](https://github.com/ElementsProject/) in a [docker container](https://gitlab.com/nolim1t/docker-clightning) for easy orchestration on embedded devices (like the Raspberry Pi), and auto-building. +Also to enable [FullyNoded](https://github.com/Fonta1n3/FullyNoded/) (currently, and maybe other stuff in future) to work properly, I've also bundled in the [http rpc plugin](https://github.com/Start9Labs/c-lightning-http-plugin) by [Start9Labs](https://github.com/Start9Labs). + ## Why? To do cross-platform builds the [LNCM](https://github.com/lncm/) way, like some of my other containers @@ -65,12 +67,32 @@ docker run -it --rm \ lncm/clightning:v0.9.1 ``` +## Using the RPC Interface + +You will need to add the following to your config file: + +* `http-user` +* `http-pass` +* `http-bind` (hostname and port) + +Then you can pass whatever RPC commands to your C Lightning node! + +Example: + +```bash +curl "http://lightning:lightningpass@localhost:1312" \ + -d '{"id": "rpctest", "method": "getinfo", "params": []}' +``` + +Please keep in mind the RPC is probably not fully hardened for public internet access. You may want to put this behind a https proxy or TOR node! ## Todo +Most stuff is in the [issues list](https://gitlab.com/nolim1t/docker-clightning/-/issues) however the below is kept for legacy purposes + - [x] Document how to build this project for more advanced users - [x] Document how to use this container (config files, etc) - [x] Build a docker compose file as an example - [x] Build a gitlab action. Gitlab will be the main focus for this project - [x] Build a github action. Github will be the secondary focus for this. -- [ ] Get the other shitcoin stuff working (Litecoin) +- [ ] Extremely low priority. Get the other shitcoin stuff working (Litecoin) diff --git a/doc/config.dist b/doc/config.dist index e7e92af..30be719 100644 --- a/doc/config.dist +++ b/doc/config.dist @@ -1,4 +1,5 @@ -# c-lightning config Default (master doc https://github.com/ElementsProject/lightning/blob/master/doc/lightningd-config.5) +# c-lightning config Default +# docs https://github.com/ElementsProject/lightning/blob/master/doc/lightningd-config.5.md # Uncomment if staying offline (good for maintenance) #offline @@ -16,6 +17,17 @@ autocleaninvoice-expired-by=7200 bind-addr=0.0.0.0 +# Default plugindir +plugin-dir=/data/.lightning/plugins + +# http plugin +#plugin=/rust-plugin/c-lightning-http-plugin/target/release/c-lightning-http-plugin +# http plugin configurables +# https://github.com/Start9Labs/c-lightning-http-plugin/blob/master/src/rpc.rs +http-user=lncm +http-pass=lncmrocks +http-bind=0.0.0.0:1312 + # For additional advertising addresses (tor / ipv5 / ipv4 / etc) #announce-addr= diff --git a/scripts/docker-entrypoint.sh b/scripts/docker-entrypoint.sh new file mode 100755 index 0000000..92c3d45 --- /dev/null +++ b/scripts/docker-entrypoint.sh @@ -0,0 +1,26 @@ +#!/usr/bin/env bash + +# Original file (Upstream) +# https://raw.githubusercontent.com/ElementsProject/lightning/master/tools/docker-entrypoint.sh +# modified to include plugin path for building my custom container + +: "${EXPOSE_TCP:=false}" + +networkdatadir="${LIGHTNINGD_DATA}/${LIGHTNINGD_NETWORK}" +HTTP_RPC_PLUGIN_PATH="/rust-plugin/c-lightning-http-plugin/target/release/c-lightning-http-plugin" + +if [ "$EXPOSE_TCP" == "true" ]; then + set -m + lightningd --plugin="${HTTP_RPC_PLUGIN_PATH}" "$@" & + + echo "C-Lightning starting" + while read -r 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:${networkdatadir}/lightning-rpc" & + fg %- +else + exec lightningd --network="${LIGHTNINGD_NETWORK}" --plugin="${HTTP_RPC_PLUGIN_PATH}" "$@" +fi