diff --git a/docker/.env b/docker/.env new file mode 100644 index 000000000..eaefb235d --- /dev/null +++ b/docker/.env @@ -0,0 +1,19 @@ +BITCOIN_HOST=bitcoind +BITCOIN_PORT=18889 +BITCOIN_RPC_USER=bitcoin +BITCOIN_RPC_PASSWORD=bitcoin +BITCOIN_RPC_PORT=18888 +BITCOIN_ZMQ_TX_PORT=28888 +BITCOIN_ZMQ_BLOCK_PORT=28889 + +LIGHTNING_HOST=lnd +LIGHTNING_PORT=9735 +LIGHTNING_RPC_PORT=10009 +LIGHTNING_REST_PORT=8080 + +RTL_PORT=3000 +RTL_NODE_AUTH_TYPE=CUSTOM +RTL_PASS=changeme + +COMPOSE_FILE=docker-compose.yml +COMPOSE_PROJECT_NAME=rtldev diff --git a/docker/README.md b/docker/README.md new file mode 100644 index 000000000..ba051f102 --- /dev/null +++ b/docker/README.md @@ -0,0 +1,51 @@ +# RTL Docker Dev Setup + +### This is not suitable for production deployments. ONLY FOR DEVELOPMENT. + +This `docker-compose` template launches `bitcoind`, `lnd` and `rtl` containers. + +It is configured to run in **regtest** mode but can be modified to suit your needs. + +### Notes + - `bitcoind` is built from an Ubuntu repository and should not be used in production. + - `lnd` will not sync to chain until Bitcoin regtest blocks are generated (see below). + - `rtl` image is from the Docker Hub repository but you can change this to your needs. + - Various ports and configs can be adjusted in the `.env` or `docker-compose.yml` files. + +## How to run +It may take several minutes if containers need to be built. From the terminal in this folder: + +``` +$ docker-compose up -d bitcoind +$ bin/b-cli generate 101 +$ docker-compose up -d lnd rtl +``` + +Check containers are up and running with: +``` +$ docker-compose ps +``` + +Use the cli tools to get responses from the containers: +``` +$ bin/ln-cli getinfo +$ bin/b-cli getblockchaininfo +``` + +View daemon logs as follows: +``` +$ docker-compose logs bitcoind lnd rtl +``` + +Once the containers are running you can access the RTL UI at http://localhost:3000 + + - Default password is `changeme`. + - Default host, port and password can be changed in `.env`. + +When you are done you can destroy containers with: +``` +$ docker-compose down -v +``` + +--- +@hashamadeus on Twitter diff --git a/docker/bin/b-cli b/docker/bin/b-cli new file mode 100755 index 000000000..d43ba4d41 --- /dev/null +++ b/docker/bin/b-cli @@ -0,0 +1,10 @@ +#!/usr/bin/env bash + +source .env + +docker-compose exec bitcoind bitcoin-cli \ + -datadir=/bitcoin \ + -rpcuser=$BITCOIN_RPC_USER \ + -rpcpassword=$BITCOIN_RPC_PASSWORD \ + -rpcport=$BITCOIN_RPC_PORT \ + "$@" \ No newline at end of file diff --git a/docker/bin/ln-cli b/docker/bin/ln-cli new file mode 100755 index 000000000..0ef12af10 --- /dev/null +++ b/docker/bin/ln-cli @@ -0,0 +1,8 @@ +#!/usr/bin/env bash + +source .env + +docker-compose exec lnd lncli \ + --macaroonpath /shared/admin.macaroon \ + --tlscertpath /shared/tls.cert \ + "$@" \ No newline at end of file diff --git a/docker/bitcoind/Dockerfile b/docker/bitcoind/Dockerfile new file mode 100644 index 000000000..def696ca3 --- /dev/null +++ b/docker/bitcoind/Dockerfile @@ -0,0 +1,10 @@ +FROM ubuntu:18.04 + +RUN apt-get -qq update && apt-get install -y software-properties-common + +RUN add-apt-repository -y ppa:bitcoin/bitcoin \ + && add-apt-repository -y universe && apt-get update + +RUN apt-get install -y bitcoind + +ADD ./bitcoin.conf /bitcoin/bitcoin.conf diff --git a/docker/bitcoind/bitcoin.conf b/docker/bitcoind/bitcoin.conf new file mode 100644 index 000000000..0e320e917 --- /dev/null +++ b/docker/bitcoind/bitcoin.conf @@ -0,0 +1,2 @@ +daemon=0 +printtoconsole=1 \ No newline at end of file diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml new file mode 100644 index 000000000..a4d25adb1 --- /dev/null +++ b/docker/docker-compose.yml @@ -0,0 +1,86 @@ +version: "2.4" + +volumes: + bitcoin_data: + lightning_data: + lightning_shared: + +services: + bitcoind: + container_name: ${COMPOSE_PROJECT_NAME}_bitcoind + image: bitcoind:0.17.1 + build: ./bitcoind + command: [ + "bitcoind", + "-datadir=/bitcoin", + "-port=${BITCOIN_PORT}", + "-upnp=0", + "-dnsseed=0", + "-txindex=1", + "-listen=0", + "-onlynet=ipv4", + "-regtest=1", + "-regtest.rpcport=${BITCOIN_RPC_PORT}", + "-regtest.port=${BITCOIN_PORT}", + "-rpcport=${BITCOIN_RPC_PORT}", + "-rpcuser=${BITCOIN_RPC_USER}", + "-rpcpassword=${BITCOIN_RPC_PASSWORD}", + "-rpcallowip=0.0.0.0/0", + "-zmqpubrawtx=tcp://0.0.0.0:${BITCOIN_ZMQ_TX_PORT}", + "-zmqpubrawblock=tcp://0.0.0.0:${BITCOIN_ZMQ_BLOCK_PORT}", + "-zmqpubhashblock=tcp://0.0.0.0:${BITCOIN_ZMQ_BLOCK_PORT}" + ] + ports: + - "${BITCOIN_PORT}:${BITCOIN_PORT}" + volumes: + - bitcoin_data:/bitcoin + + lnd: + container_name: ${COMPOSE_PROJECT_NAME}_lnd + image: lnd:0.5.2-beta + build: ./lnd + restart: unless-stopped + command: [ + "lnd", + "--noseedbackup", + "--rpclisten=0.0.0.0:${LIGHTNING_RPC_PORT}", + "--restlisten=0.0.0.0:${LIGHTNING_REST_PORT}", + "--adminmacaroonpath=/shared/admin.macaroon", + "--tlsextradomain=${LIGHTNING_HOST}", + "--tlsextraip=0.0.0.0", + "--tlscertpath=/shared/tls.cert", + "--datadir=/lnd", + "--bitcoin.active", + "--bitcoin.regtest", + "--bitcoin.node=bitcoind", + "--bitcoind.rpchost=${BITCOIN_HOST}:${BITCOIN_RPC_PORT}", + "--bitcoind.rpcuser=${BITCOIN_RPC_USER}", + "--bitcoind.rpcpass=${BITCOIN_RPC_PASSWORD}", + "--bitcoind.zmqpubrawtx=tcp://${BITCOIN_HOST}:${BITCOIN_ZMQ_TX_PORT}", + "--bitcoind.zmqpubrawblock=tcp://${BITCOIN_HOST}:${BITCOIN_ZMQ_BLOCK_PORT}" + ] + depends_on: + - bitcoind + ports: + - "${LIGHTNING_REST_PORT}:${LIGHTNING_REST_PORT}" + volumes: + - lightning_data:/lnd + - lightning_shared:/shared + + rtl: + container_name: ${COMPOSE_PROJECT_NAME}_rtl + image: shahanafarooqui/rtl:0.2.16 + restart: unless-stopped + depends_on: + - lnd + volumes: + - lightning_shared:/shared:ro + ports: + - "${RTL_PORT}:${RTL_PORT}" + environment: + PORT: ${RTL_PORT} + MACAROON_PATH: /shared + LND_SERVER_URL: https://${LIGHTNING_HOST}:${LIGHTNING_REST_PORT}/v1 + LND_CONFIG_PATH: '' + NODE_AUTH_TYPE: ${RTL_NODE_AUTH_TYPE} + RTL_PASS: ${RTL_PASS} \ No newline at end of file diff --git a/docker/lnd/Dockerfile b/docker/lnd/Dockerfile new file mode 100644 index 000000000..65297f0d5 --- /dev/null +++ b/docker/lnd/Dockerfile @@ -0,0 +1,29 @@ +FROM golang:1.11-alpine as builder + +WORKDIR /go/src/github.com/lightningnetwork/lnd + +# Force Go to use the cgo based DNS resolver. This is required to ensure DNS +# queries required to connect to linked containers succeed. +ENV GODEBUG netdns=cgo + +RUN apk add --no-cache --update alpine-sdk git make \ + && git clone -n https://github.com/lightningnetwork/lnd . \ + && git checkout d2186cc9da29853091175189268b073f49586cf0 \ + && make \ + && make install + +# Start a new, final image to reduce size. +FROM alpine as final + +# Expose lnd ports (server, rpc). +EXPOSE 9735 10009 + +# Copy the binaries and entrypoint from the builder image. +COPY --from=builder /go/bin/lncli /bin/ +COPY --from=builder /go/bin/lnd /bin/ + +# Add bash. +RUN apk add --no-cache bash + +# Import the config +ADD ./lnd.conf /root/.lnd/lnd.conf \ No newline at end of file diff --git a/docker/lnd/lnd.conf b/docker/lnd/lnd.conf new file mode 100644 index 000000000..a9c971406 --- /dev/null +++ b/docker/lnd/lnd.conf @@ -0,0 +1,2 @@ +[Application Options] +debuglevel=info \ No newline at end of file