Skip to content

Commit

Permalink
Acktuallly... no need to put this in the build stage.. should be in t…
Browse files Browse the repository at this point in the history
…he final. Python is already there ;)
  • Loading branch information
nolim1t committed Nov 20, 2020
1 parent cd49a76 commit 8767df0
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 16 deletions.
41 changes: 27 additions & 14 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -39,42 +39,55 @@ 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
ARG DATA

LABEL maintainer="nolim1t ([email protected])"

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
Expand Down
24 changes: 23 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
14 changes: 13 additions & 1 deletion doc/config.dist
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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=

Expand Down
26 changes: 26 additions & 0 deletions scripts/docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 8767df0

Please sign in to comment.