diff --git a/docker/lnd/Dockerfile b/docker/lnd/Dockerfile index f7e2731c..caba2ed1 100644 --- a/docker/lnd/Dockerfile +++ b/docker/lnd/Dockerfile @@ -1,39 +1,62 @@ -FROM golang:1.13-alpine as builder - -MAINTAINER Olaoluwa Osuntokun - -RUN apk update && \ - apk upgrade && \ - apk add git - -# Copy in the local repository to build from. -RUN git clone https://github.com/lightningnetwork/lnd.git --branch v0.13.1-beta +# If you change this value, please change it in the following files as well: +# /.travis.yml +# /dev.Dockerfile +# /make/builder.Dockerfile +# /.github/workflows/main.yml +# /.github/workflows/release.yml +FROM golang:1.16.3-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 install/build lnd. +# Pass a tag, branch or a commit using build-arg. This allows a docker +# image to be built from a specified Git state. The default image +# will use the Git tip of master by default. +# ARG checkout="master" +ARG checkout="v0.13.1-beta" + +# Install dependencies and build the binaries. RUN apk add --no-cache --update alpine-sdk \ git \ make \ -&& cd lnd \ -&& make \ -&& make install + gcc \ +&& git clone https://github.com/lightningnetwork/lnd /go/src/github.com/lightningnetwork/lnd \ +&& cd /go/src/github.com/lightningnetwork/lnd \ +&& git checkout $checkout \ +&& make release-install -# Start a new, final image to reduce size. +# Start a new, final image. FROM alpine as final -# Expose lnd ports (server, rpc). -EXPOSE 9735 10009 +# Define a root volume for data persistence. +VOLUME /root/.lnd -# Copy the binaries and entrypoint from the builder image. +# Add utilities for quality of life and SSL-related reasons. We also require +# curl and gpg for the signature verification script. +RUN apk --no-cache add \ + bash \ + jq \ + ca-certificates \ + gnupg \ + curl + +# Copy the binaries from the builder image. COPY --from=builder /go/bin/lncli /bin/ COPY --from=builder /go/bin/lnd /bin/ +COPY --from=builder /go/src/github.com/lightningnetwork/lnd/scripts/verify-install.sh / -# Add bash. +# Store the SHA256 hash of the binaries that were just produced for later +# verification. +RUN sha256sum /bin/lnd /bin/lncli > /shasums.txt \ + && cat /shasums.txt + +# Install dependencies and build the binaries. RUN apk add --no-cache \ - bash + procps + +# Expose lnd ports (p2p, rpc). +EXPOSE 9735 10009 # Copy the entrypoint script. COPY "docker/lnd/start-lnd.sh" . diff --git a/docker/lnd/start-lnd.sh b/docker/lnd/start-lnd.sh index 75fc741e..6e51aada 100644 --- a/docker/lnd/start-lnd.sh +++ b/docker/lnd/start-lnd.sh @@ -76,8 +76,6 @@ elif [[ "$BACKEND" == "bitcoind" ]]; then $@" echo $cmd sh ./wait-for-block-index.sh "$cmd" - echo "Finished waiting for loading block index." - exec $cmd else exec lnd \ --noseedbackup \ diff --git a/docker/lnd/wait-for-block-index.sh b/docker/lnd/wait-for-block-index.sh index 3c91f6fb..fb638877 100644 --- a/docker/lnd/wait-for-block-index.sh +++ b/docker/lnd/wait-for-block-index.sh @@ -12,9 +12,15 @@ do echo "Trying to run cmd: $CMD" >&2 eval $CMD & last_pid=$! - sleep 30 - if kill $last_pid > /dev/null 2>&1; then + echo "Starting lnd with pid: $last_pid" >&2 + echo "Sleeping for 20 seconds..." + sleep 20 + if ps -p $last_pid; then echo "Found running process for pid: $last_pid" >&2 READY=1 + wait $last_pid + else + echo "Sleeping for 5 seconds..." + sleep 5 fi done