From b7b27385bff82c0e3f31fdd51259a22001de4bec Mon Sep 17 00:00:00 2001 From: "nicolas.dorier" Date: Tue, 10 Jul 2018 19:35:12 +0900 Subject: [PATCH 1/3] Create Dockerfile for btcpay --- .dockerignore | 2 ++ .gitattributes | 4 +++ BTCPayServer.Dockerfile | 43 +++++++++++++++++++++++++++++++ docker-entrypoint.sh | 56 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 105 insertions(+) create mode 100644 .dockerignore create mode 100644 .gitattributes create mode 100644 BTCPayServer.Dockerfile create mode 100755 docker-entrypoint.sh diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000000..095b6f1a40 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,2 @@ +Dockerfile +BTCPayServer.Dockerfile \ No newline at end of file diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000000..6fcdd9127c --- /dev/null +++ b/.gitattributes @@ -0,0 +1,4 @@ +# Declare files that will always have CRLF line endings on checkout. +*.sh text eol=lf +*.go text eol=lf +Makefile text eol=lf diff --git a/BTCPayServer.Dockerfile b/BTCPayServer.Dockerfile new file mode 100644 index 0000000000..a331eda4b2 --- /dev/null +++ b/BTCPayServer.Dockerfile @@ -0,0 +1,43 @@ +FROM golang:alpine as builder + +# 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 + +# Install dependencies and build the binaries. +RUN apk add --no-cache \ + git \ + make + +WORKDIR /go/src/github.com/lightningnetwork/lnd +COPY . . + +RUN make \ +&& make install + +# Start a new, final image. +FROM alpine as final + +# Add bash and ca-certs, for quality of life and SSL-related reasons. +RUN apk --no-cache add \ + bash \ + ca-certificates + +ENV LND_DATA /data +ENV LND_BITCOIND /deps/.bitcoin +ENV LND_BTCD /deps/.btcd + +RUN mkdir "$LND_DATA" && mkdir "/deps" && mkdir "$LND_BITCOIND" && mkdir "$LND_BTCD" && \ + ln -sfn "$LND_DATA" /root/.lnd && ln -sfn "$LND_BITCOIND" /root/.bitcoin && ln -sfn "$LND_BTCD" /root/.btcd + +# Define a root volume for data persistence. +VOLUME /data + +# Copy the binaries from the builder image. +COPY --from=builder /go/bin/lncli /bin/ +COPY --from=builder /go/bin/lnd /bin/ + +COPY docker-entrypoint.sh /docker-entrypoint.sh +# Specify the start command and entrypoint as the lnd daemon. +ENTRYPOINT ["/docker-entrypoint.sh"] +CMD ["lnd"] diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh new file mode 100755 index 0000000000..f990c9e475 --- /dev/null +++ b/docker-entrypoint.sh @@ -0,0 +1,56 @@ +#!/bin/bash +set -e + +if [[ "$1" == "lnd" || "$1" == "lncli" ]]; then + mkdir -p "$LND_DATA" + + cat <<-EOF > "$LND_DATA/lnd.conf" + ${LND_EXTRA_ARGS} + EOF + + if [[ $LND_CHAIN && $LND_ENVIRONMENT ]]; then + echo "LND_CHAIN=$LND_CHAIN" + echo "LND_ENVIRONMENT=$LND_ENVIRONMENT" + + NETWORK="" + + shopt -s nocasematch + if [[ $LND_CHAIN == "btc" ]]; then + NETWORK="bitcoin" + elif [[ $LND_CHAIN == "ltc" ]]; then + NETWORK="litecoin" + else + echo "Unknwon value for LND_CHAIN, expected btc or ltc" + fi + + ENV="" + # Make sure we use correct casing for LND_Environment + if [[ $LND_ENVIRONMENT == "mainnet" ]]; then + ENV="mainnet" + elif [[ $LND_ENVIRONMENT == "testnet" ]]; then + ENV="testnet" + elif [[ $LND_ENVIRONMENT == "regtest" ]]; then + ENV="regtest" + else + echo "Unknwon value for LND_ENVIRONMENT, expected mainnet, testnet or regtest" + fi + shopt -u nocasematch + + if [[ $ENV && $NETWORK ]]; then + echo " + $NETWORK.active=1 + $NETWORK.$LND_ENVIRONMENT=1 + " >> "$LND_DATA/lnd.conf" + echo "Added $NETWORK.active and $NETWORK.$LND_ENVIRONMENT to config file $LND_DATA/lnd.conf" + else + echo "LND_CHAIN or LND_ENVIRONMENT is not set correctly" + fi + fi + + ln -sfn "$LND_DATA" /root/.lnd + ln -sfn "$LND_BITCOIND" /root/.bitcoin + ln -sfn "$LND_BTCD" /root/.btcd + exec "$@" +else + exec "$@" +fi From c2e2a722df65852540acee1f11d74751b29ab93d Mon Sep 17 00:00:00 2001 From: Vutov Date: Mon, 16 Jul 2018 15:36:20 +0300 Subject: [PATCH 2/3] BTG Changes --- BTCPayServer.Dockerfile | 6 +++--- docker-entrypoint.sh | 8 +++----- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/BTCPayServer.Dockerfile b/BTCPayServer.Dockerfile index a331eda4b2..1120cfb2da 100644 --- a/BTCPayServer.Dockerfile +++ b/BTCPayServer.Dockerfile @@ -9,7 +9,7 @@ RUN apk add --no-cache \ git \ make -WORKDIR /go/src/github.com/lightningnetwork/lnd +WORKDIR /go/src/github.com/shelvenzhou/lnd COPY . . RUN make \ @@ -24,11 +24,11 @@ RUN apk --no-cache add \ ca-certificates ENV LND_DATA /data -ENV LND_BITCOIND /deps/.bitcoin +ENV LND_BITCOIND /deps/.bitcoingold ENV LND_BTCD /deps/.btcd RUN mkdir "$LND_DATA" && mkdir "/deps" && mkdir "$LND_BITCOIND" && mkdir "$LND_BTCD" && \ - ln -sfn "$LND_DATA" /root/.lnd && ln -sfn "$LND_BITCOIND" /root/.bitcoin && ln -sfn "$LND_BTCD" /root/.btcd + ln -sfn "$LND_DATA" /root/.lnd && ln -sfn "$LND_BITCOIND" /root/.bitcoingold && ln -sfn "$LND_BTCD" /root/.btcd # Define a root volume for data persistence. VOLUME /data diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index f990c9e475..1e2ded1e22 100755 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -15,10 +15,8 @@ if [[ "$1" == "lnd" || "$1" == "lncli" ]]; then NETWORK="" shopt -s nocasematch - if [[ $LND_CHAIN == "btc" ]]; then - NETWORK="bitcoin" - elif [[ $LND_CHAIN == "ltc" ]]; then - NETWORK="litecoin" + if [[ $LND_CHAIN == "btg" ]]; then + NETWORK="bitcoingold" else echo "Unknwon value for LND_CHAIN, expected btc or ltc" fi @@ -48,7 +46,7 @@ if [[ "$1" == "lnd" || "$1" == "lncli" ]]; then fi ln -sfn "$LND_DATA" /root/.lnd - ln -sfn "$LND_BITCOIND" /root/.bitcoin + ln -sfn "$LND_BITCOIND" /root/.bitcoingold ln -sfn "$LND_BTCD" /root/.btcd exec "$@" else From 3150fe23d5156fd08f20c09d3139fdeea536e797 Mon Sep 17 00:00:00 2001 From: Vutov Date: Thu, 19 Jul 2018 20:54:21 +0300 Subject: [PATCH 3/3] Docker change for partial setting up of rpc params --- config.go | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/config.go b/config.go index 1c0ffa6124..98a61fd3a9 100644 --- a/config.go +++ b/config.go @@ -1020,14 +1020,7 @@ func parseRPCParams(cConfig *chainConfig, nodeConfig interface{}, net chainCode, case bitcoingoldChain: daemonName = "bgoldd" } - // If only one or two of the parameters are set, we assume the - // user did that unintentionally. - if conf.RPCUser != "" || conf.RPCPass != "" || conf.ZMQPath != "" { - return fmt.Errorf("please set all or none of "+ - "%[1]v.rpcuser, %[1]v.rpcpass, "+ - "and %[1]v.zmqpath", daemonName) - } - + switch net { case bitcoingoldChain: confDir = conf.Dir @@ -1074,7 +1067,15 @@ func parseRPCParams(cConfig *chainConfig, nodeConfig interface{}, net chainCode, " %v, cannot start w/o RPC connection", err) } - nConf.RPCUser, nConf.RPCPass, nConf.ZMQPath = rpcUser, rpcPass, zmqPath + if nConf.RPCUser == "" { + nConf.RPCUser = rpcUser + } + if nConf.RPCPass == "" { + nConf.RPCPass = rpcPass + } + if nConf.ZMQPath == "" { + nConf.ZMQPath = zmqPath + } } fmt.Printf("Automatically obtained %v's RPC credentials\n", daemonName)