Skip to content

Commit ef50a1f

Browse files
committed
Merge branch 'rust-python-plugin-support' into 'master'
Rust python plugin support Closes #2 See merge request nolim1t/docker-clightning!1
2 parents cd49a76 + 8767df0 commit ef50a1f

File tree

4 files changed

+89
-16
lines changed

4 files changed

+89
-16
lines changed

Dockerfile

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -39,42 +39,55 @@ ARG VERSION
3939
ARG REPO
4040

4141
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
42+
ARG DEVELOPER=0
4243

4344
WORKDIR /opt
44-
RUN git clone $REPO
45-
WORKDIR /opt/lightning
46-
RUN ls -la
47-
RUN mkdir -p /tmp/lightning_install
48-
49-
RUN git checkout $VERSION
50-
#RUN git clone --recursive /tmp/lightning . && \
51-
# git checkout $(git --work-tree=/tmp/lightning --git-dir=/tmp/lightning/.git rev-parse HEAD)
52-
53-
ARG DEVELOPER=0
54-
RUN ./configure --prefix=/tmp/lightning_install --enable-static && make -j3 DEVELOPER=${DEVELOPER} && make install
45+
RUN git clone $REPO && \
46+
cd lightning && \
47+
ls -la && \
48+
mkdir -p /tmp/lightning_install && \
49+
ls -la /tmp && \
50+
git checkout $VERSION && \
51+
./configure --prefix=/tmp/lightning_install \
52+
--enable-static && \
53+
make -j3 DEVELOPER=${DEVELOPER} && \
54+
make install && \
55+
ls -la /tmp/lightning_install
5556

5657
FROM debian:buster-slim as final
5758
ARG USER
5859
ARG DATA
5960

6061
LABEL maintainer="nolim1t (hello@nolim1t.co)"
6162

62-
RUN apt-get update && apt-get install -y --no-install-recommends socat inotify-tools python3 python3-pip \
63+
RUN apt-get update && apt-get install -y --no-install-recommends git socat inotify-tools python3 python3-pip cargo \
6364
&& rm -rf /var/lib/apt/lists/*
6465

6566

6667
COPY --from=builder /lib /lib
6768
COPY --from=builder /tmp/lightning_install/ /usr/local/
6869
COPY --from=downloader /opt/bin /usr/bin
69-
COPY --from=builder /opt/lightning/tools/docker-entrypoint.sh entrypoint.sh
70+
COPY ./scripts/docker-entrypoint.sh entrypoint.sh
71+
72+
RUN mkdir /rust-plugin && \
73+
chown 1000.1000 /rust-plugin
7074

7175
RUN adduser --disabled-password \
7276
--home "$DATA" \
7377
--gecos "" \
7478
"$USER"
75-
7679
USER $USER
7780

81+
# Build and install http rust plugin to the following dir
82+
# /rust-plugin/c-lightning-http-plugin/target/release/c-lightning-http-plugin
83+
RUN cd /rust-plugin && \
84+
git clone https://github.com/Start9Labs/c-lightning-http-plugin.git && \
85+
cd c-lightning-http-plugin && \
86+
cargo build --release && \
87+
ls -la target/release/c-lightning-http-plugin && \
88+
pwd
89+
90+
7891
ENV LIGHTNINGD_DATA=$DATA/.lightning
7992
ENV LIGHTNINGD_RPC_PORT=9835
8093
ENV LIGHTNINGD_PORT=9735

README.md

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
[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.
1212

13+
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).
14+
1315
## Why?
1416

1517
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 \
6567
lncm/clightning:v0.9.1
6668
```
6769

70+
## Using the RPC Interface
71+
72+
You will need to add the following to your config file:
73+
74+
* `http-user`
75+
* `http-pass`
76+
* `http-bind` (hostname and port)
77+
78+
Then you can pass whatever RPC commands to your C Lightning node!
79+
80+
Example:
81+
82+
```bash
83+
curl "http://lightning:lightningpass@localhost:1312" \
84+
-d '{"id": "rpctest", "method": "getinfo", "params": []}'
85+
```
86+
87+
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!
6888

6989
## Todo
7090

91+
Most stuff is in the [issues list](https://gitlab.com/nolim1t/docker-clightning/-/issues) however the below is kept for legacy purposes
92+
7193
- [x] Document how to build this project for more advanced users
7294
- [x] Document how to use this container (config files, etc)
7395
- [x] Build a docker compose file as an example
7496
- [x] Build a gitlab action. Gitlab will be the main focus for this project
7597
- [x] Build a github action. Github will be the secondary focus for this.
76-
- [ ] Get the other shitcoin stuff working (Litecoin)
98+
- [ ] Extremely low priority. Get the other shitcoin stuff working (Litecoin)

doc/config.dist

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
# c-lightning config Default (master doc https://github.com/ElementsProject/lightning/blob/master/doc/lightningd-config.5)
1+
# c-lightning config Default
2+
# docs https://github.com/ElementsProject/lightning/blob/master/doc/lightningd-config.5.md
23

34
# Uncomment if staying offline (good for maintenance)
45
#offline
@@ -16,6 +17,17 @@ autocleaninvoice-expired-by=7200
1617

1718
bind-addr=0.0.0.0
1819

20+
# Default plugindir
21+
plugin-dir=/data/.lightning/plugins
22+
23+
# http plugin
24+
#plugin=/rust-plugin/c-lightning-http-plugin/target/release/c-lightning-http-plugin
25+
# http plugin configurables
26+
# https://github.com/Start9Labs/c-lightning-http-plugin/blob/master/src/rpc.rs
27+
http-user=lncm
28+
http-pass=lncmrocks
29+
http-bind=0.0.0.0:1312
30+
1931
# For additional advertising addresses (tor / ipv5 / ipv4 / etc)
2032
#announce-addr=
2133

scripts/docker-entrypoint.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/usr/bin/env bash
2+
3+
# Original file (Upstream)
4+
# https://raw.githubusercontent.com/ElementsProject/lightning/master/tools/docker-entrypoint.sh
5+
# modified to include plugin path for building my custom container
6+
7+
: "${EXPOSE_TCP:=false}"
8+
9+
networkdatadir="${LIGHTNINGD_DATA}/${LIGHTNINGD_NETWORK}"
10+
HTTP_RPC_PLUGIN_PATH="/rust-plugin/c-lightning-http-plugin/target/release/c-lightning-http-plugin"
11+
12+
if [ "$EXPOSE_TCP" == "true" ]; then
13+
set -m
14+
lightningd --plugin="${HTTP_RPC_PLUGIN_PATH}" "$@" &
15+
16+
echo "C-Lightning starting"
17+
while read -r i; do if [ "$i" = "lightning-rpc" ]; then break; fi; done \
18+
< <(inotifywait -e create,open --format '%f' --quiet "${networkdatadir}" --monitor)
19+
echo "C-Lightning started"
20+
echo "C-Lightning started, RPC available on port $LIGHTNINGD_RPC_PORT"
21+
22+
socat "TCP4-listen:$LIGHTNINGD_RPC_PORT,fork,reuseaddr" "UNIX-CONNECT:${networkdatadir}/lightning-rpc" &
23+
fg %-
24+
else
25+
exec lightningd --network="${LIGHTNINGD_NETWORK}" --plugin="${HTTP_RPC_PLUGIN_PATH}" "$@"
26+
fi

0 commit comments

Comments
 (0)