mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-02-20 13:54:36 +01:00
docker: Add a usable dockerfile
This is based on @NicolasDorier's excellent proposal for a Dockerfile, sans the writing of a config file. Co-authored-by: Nicolas Dorier <nicolas.dorier@gmail.com> Co-authored-by: Christian Decker <decker.christian@gmail.com> Signed-off-by: Christian Decker <decker.christian@gmail.com>
This commit is contained in:
parent
1899e000d6
commit
0d3c3a225e
4 changed files with 173 additions and 7 deletions
2
.gitattributes
vendored
2
.gitattributes
vendored
|
@ -1,4 +1,4 @@
|
|||
# Declare files that will always have CRLF line endings on checkout.
|
||||
*.sh text eol=lf
|
||||
*.py text eol=lf
|
||||
Makefile text eol=lf
|
||||
Makefile text eol=lf
|
||||
|
|
103
Dockerfile
Normal file
103
Dockerfile
Normal file
|
@ -0,0 +1,103 @@
|
|||
FROM alpine:3.7 as builder
|
||||
|
||||
RUN apk add --no-cache \
|
||||
ca-certificates \
|
||||
autoconf \
|
||||
automake \
|
||||
build-base \
|
||||
libressl \
|
||||
libtool \
|
||||
gmp-dev \
|
||||
python \
|
||||
python-dev \
|
||||
python3 \
|
||||
sqlite-dev \
|
||||
wget \
|
||||
git \
|
||||
file \
|
||||
gnupg \
|
||||
swig \
|
||||
zlib-dev
|
||||
|
||||
WORKDIR /opt
|
||||
|
||||
ENV BITCOIN_VERSION 0.16.0
|
||||
ENV BITCOIN_URL https://bitcoincore.org/bin/bitcoin-core-$BITCOIN_VERSION/bitcoin-$BITCOIN_VERSION-x86_64-linux-gnu.tar.gz
|
||||
ENV BITCOIN_SHA256 e6322c69bcc974a29e6a715e0ecb8799d2d21691d683eeb8fef65fc5f6a66477
|
||||
ENV BITCOIN_ASC_URL https://bitcoincore.org/bin/bitcoin-core-$BITCOIN_VERSION/SHA256SUMS.asc
|
||||
ENV BITCOIN_PGP_KEY 01EA5486DE18A882D4C2684590C8019E36C2E964
|
||||
|
||||
RUN mkdir /opt/bitcoin && cd /opt/bitcoin \
|
||||
&& wget -qO bitcoin.tar.gz "$BITCOIN_URL" \
|
||||
&& echo "$BITCOIN_SHA256 bitcoin.tar.gz" | sha256sum -c - \
|
||||
&& gpg --keyserver keyserver.ubuntu.com --recv-keys "$BITCOIN_PGP_KEY" \
|
||||
&& wget -qO bitcoin.asc "$BITCOIN_ASC_URL" \
|
||||
&& gpg --verify bitcoin.asc \
|
||||
&& BD=bitcoin-$BITCOIN_VERSION/bin \
|
||||
&& tar -xzvf bitcoin.tar.gz $BD/bitcoin-cli --strip-components=1 \
|
||||
&& rm bitcoin.tar.gz
|
||||
|
||||
ENV LITECOIN_VERSION 0.14.2
|
||||
ENV LITECOIN_URL https://download.litecoin.org/litecoin-0.14.2/linux/litecoin-0.14.2-x86_64-linux-gnu.tar.gz
|
||||
ENV LITECOIN_SHA256 05f409ee57ce83124f2463a3277dc8d46fca18637052d1021130e4deaca07b3c
|
||||
ENV LITECOIN_ASC_URL https://download.litecoin.org/litecoin-0.14.2/linux/litecoin-0.14.2-linux-signatures.asc
|
||||
ENV LITECOIN_PGP_KEY FE3348877809386C
|
||||
|
||||
# install litecoin binaries
|
||||
RUN mkdir /opt/litecoin && cd /opt/litecoin \
|
||||
&& wget -qO litecoin.tar.gz "$LITECOIN_URL" \
|
||||
&& echo "$LITECOIN_SHA256 litecoin.tar.gz" | sha256sum -c - \
|
||||
&& gpg --keyserver keyserver.ubuntu.com --recv-keys "$LITECOIN_PGP_KEY" \
|
||||
&& wget -qO litecoin.asc "$LITECOIN_ASC_URL" \
|
||||
&& gpg --verify litecoin.asc \
|
||||
&& BD=litecoin-$LITECOIN_VERSION/bin \
|
||||
&& tar -xzvf litecoin.tar.gz $BD/litecoin-cli --strip-components=1 --exclude=*-qt \
|
||||
&& rm litecoin.tar.gz
|
||||
|
||||
ENV LIGHTNINGD_VERSION=master
|
||||
|
||||
WORKDIR /opt/lightningd
|
||||
COPY . .
|
||||
|
||||
ARG DEVELOPER=0
|
||||
RUN ./configure && make -j3 DEVELOPER=${DEVELOPER} && cp lightningd/lightning* cli/lightning-cli /usr/bin/
|
||||
|
||||
FROM alpine:3.7
|
||||
|
||||
RUN apk add --no-cache \
|
||||
gmp-dev \
|
||||
sqlite-dev \
|
||||
inotify-tools \
|
||||
socat \
|
||||
bash \
|
||||
zlib-dev
|
||||
|
||||
ENV GLIBC_VERSION 2.27-r0
|
||||
ENV GLIBC_SHA256 938bceae3b83c53e7fa9cc4135ce45e04aae99256c5e74cf186c794b97473bc7
|
||||
ENV GLIBCBIN_SHA256 3a87874e57b9d92e223f3e90356aaea994af67fb76b71bb72abfb809e948d0d6
|
||||
# Download and install glibc (https://github.com/jeanblanchard/docker-alpine-glibc/blob/master/Dockerfile)
|
||||
RUN apk add --update curl && \
|
||||
curl -Lo /etc/apk/keys/sgerrand.rsa.pub https://raw.githubusercontent.com/sgerrand/alpine-pkg-glibc/master/sgerrand.rsa.pub && \
|
||||
curl -Lo glibc.apk "https://github.com/sgerrand/alpine-pkg-glibc/releases/download/${GLIBC_VERSION}/glibc-${GLIBC_VERSION}.apk" && \
|
||||
echo "$GLIBC_SHA256 glibc.apk" | sha256sum -c - && \
|
||||
curl -Lo glibc-bin.apk "https://github.com/sgerrand/alpine-pkg-glibc/releases/download/${GLIBC_VERSION}/glibc-bin-${GLIBC_VERSION}.apk" && \
|
||||
echo "$GLIBCBIN_SHA256 glibc-bin.apk" | sha256sum -c - && \
|
||||
apk add glibc-bin.apk glibc.apk && \
|
||||
/usr/glibc-compat/sbin/ldconfig /lib /usr/glibc-compat/lib && \
|
||||
echo 'hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4' >> /etc/nsswitch.conf && \
|
||||
apk del curl && \
|
||||
rm -rf glibc.apk glibc-bin.apk /var/cache/apk/*
|
||||
|
||||
ENV LIGHTNINGD_DATA=/root/.lightning
|
||||
ENV LIGHTNINGD_PORT=9735
|
||||
|
||||
VOLUME [ "/root/.lightning" ]
|
||||
|
||||
COPY --from=builder /opt/lightningd/cli/lightning-cli /usr/bin
|
||||
COPY --from=builder /opt/lightningd/lightningd/lightning* /usr/bin/
|
||||
COPY --from=builder /opt/bitcoin/bin /usr/bin
|
||||
COPY --from=builder /opt/litecoin/bin /usr/bin
|
||||
COPY tools/docker-entrypoint.sh entrypoint.sh
|
||||
|
||||
EXPOSE 9735
|
||||
ENTRYPOINT [ "./entrypoint.sh" ]
|
57
README.md
57
README.md
|
@ -64,13 +64,58 @@ For the impatient here's the gist of it for Ubuntu and Debian:
|
|||
./configure
|
||||
make
|
||||
|
||||
Or if you like to throw `docker` into the mix:
|
||||
Or if you like to throw `docker` into the mix, you can use the offial docker image either directly or as a base layer for more complex images.
|
||||
The docker image is [elementsproject/lightningd](https://hub.docker.com/r/elementsproject/lightningd/) (from this [Dockerfile](Dockerfile)).
|
||||
Image tags with `-dev` at the end are images built with `DEVELOPER=1`.
|
||||
If you build the image yourself, you can use the build arg `DEVELOPER=1` to build c-lightning in developer mode.
|
||||
|
||||
sudo docker run \
|
||||
-v $HOME/.lightning:/root/.lightning \
|
||||
-v $HOME/.bitcoin:/root/.bitcoin \
|
||||
-p 9735:9735 \
|
||||
cdecker/lightningd:latest
|
||||
It has the following environment variable:
|
||||
|
||||
* `EXPOSE_TCP` default to false, if true, use expose c-lightning on port 9735. (Use this only for testing)
|
||||
|
||||
Here is an example of a docker-compose file with bitcoind and c-lightning on `testnet` which expose litecoin's rpc interface on default ports `18332` and c-lightning API on port `9735`:
|
||||
|
||||
```
|
||||
version: "3"
|
||||
services:
|
||||
bitcoind:
|
||||
image: nicolasdorier/docker-bitcoin:0.16.0
|
||||
environment:
|
||||
BITCOIN_EXTRA_ARGS: |
|
||||
testnet=1
|
||||
whitelist=0.0.0.0/0
|
||||
server=1
|
||||
rpcuser=rpcuser
|
||||
rpcpassword=rpcpass
|
||||
expose:
|
||||
- "18332"
|
||||
volumes:
|
||||
- "bitcoin_datadir:/data"
|
||||
|
||||
clightning_bitcoin:
|
||||
image: elementsproject/lightningd
|
||||
command:
|
||||
- lightningd
|
||||
- --bitcoin-rpcconnect=bitcoind
|
||||
- --bitcoin-rpcuser=rpcuser
|
||||
- --bitcoin-rpcpassword=rpcpass
|
||||
- --network=testnet
|
||||
- --alias=myawesomenode
|
||||
- --log-level=debug
|
||||
environment:
|
||||
EXPOSE_TCP: "true"
|
||||
expose:
|
||||
- "9735"
|
||||
volumes:
|
||||
- "clightning_bitcoin_datadir:/root/.lightning"
|
||||
- "bitcoin_datadir:/etc/bitcoin"
|
||||
links:
|
||||
- bitcoind
|
||||
|
||||
volumes:
|
||||
bitcoin_datadir:
|
||||
clightning_bitcoin_datadir:
|
||||
```
|
||||
|
||||
### Starting `lightningd`
|
||||
|
||||
|
|
18
tools/docker-entrypoint.sh
Executable file
18
tools/docker-entrypoint.sh
Executable file
|
@ -0,0 +1,18 @@
|
|||
#!/bin/bash
|
||||
|
||||
: "${EXPOSE_TCP:=false}"
|
||||
|
||||
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)
|
||||
echo "C-Lightning started"
|
||||
|
||||
socat "TCP4-listen:$LIGHTNINGD_PORT,fork,reuseaddr" "UNIX-CONNECT:$LIGHTNINGD_DATA/lightning-rpc" &
|
||||
fg %-
|
||||
else
|
||||
lightningd "$@"
|
||||
fi
|
Loading…
Add table
Reference in a new issue