add docker support

pull/1/head
Antonin Hildebrand 5 years ago
parent c8035528bb
commit ea394c75c7

@ -39,3 +39,34 @@ conn_timeout = 1000000
pool_capacity = 3
```
Change macaroon path according to your network.
## Docker
If you prefer to run `lntop` from a docker container:
```sh
cd docker
# now you should review ./lntop/config.toml
# point LND_HOME to your actual lnd directory
# we recommend using .envrc with direnv
export LND_HOME=~/.lnd
# build the container
./build.sh
# run lntop from the contaner
./lntop.sh
```
To see `lntop` logs, you can tail them in another terminal session via:
```sh
./logs.sh -f
```
To start from scratch:
```sh
./clean.sh
./build.sh --no-cache
```

1
docker/.gitignore vendored

@ -0,0 +1 @@
lntop/_src

@ -0,0 +1,16 @@
#!/usr/bin/env bash
set -e -o pipefail
cd "$(dirname "${BASH_SOURCE[0]}")"
LND_HOME=${LND_HOME:?required}
LNTOP_SRC_DIR=${LNTOP_SRC_DIR:-./..}
# we rsync repo sources to play well with docker cache
echo "Staging lntop source code..."
mkdir -p lntop/_src
rsync -a --exclude='.git/' --exclude='docker/' --exclude='README.md' --exclude='LICENSE' "$LNTOP_SRC_DIR" lntop/_src
echo "Building lntop docker container..."
exec docker-compose build "$@" lntop

@ -0,0 +1,12 @@
#!/usr/bin/env bash
set -e -o pipefail
# stop and remove all containers from lntop image (see https://stackoverflow.com/a/32074098/84283)
CONTAINERS=$(docker ps -a -q --filter ancestor=lntop --format="{{.ID}}")
if [[ -n "$CONTAINERS" ]]; then
docker rm $(docker stop ${CONTAINERS})
fi
# clean source code stage
rm -rf lntop/_src

@ -0,0 +1,25 @@
# we have a really simple setup here
# we use docker-compose only as a convenient way to specify docker build parameters via a yaml file
# you could as well use Dockerfile directly with `docker build` and config passed via command-line args
#
# tips:
# - to run lntop from docker, you can use our wrapper script ./lntop.sh
# - see other scripts in this folder, also check the docker section in the main readme
version: '3.7'
services:
lntop:
image: lntop
container_name: lntop
command: ["run"]
network_mode: host
build:
context: ./lntop
dockerfile: Dockerfile
args:
- LNTOP_SRC_PATH=_src
- LNTOP_CONF_PATH=config.toml
volumes:
- $LND_HOME:/root/.lnd

@ -0,0 +1,7 @@
#!/usr/bin/env bash
set -e -o pipefail
LND_HOME=${LND_HOME:?required}
exec docker exec -ti lntop fish

@ -0,0 +1,7 @@
#!/usr/bin/env bash
set -e -o pipefail
LND_HOME=${LND_HOME:?required}
exec docker-compose run --rm --name lntop lntop /sbin/tini -- lntop

@ -0,0 +1,45 @@
FROM golang:1.12-alpine as builder
# install build dependencies
RUN apk add --no-cache --update git gcc musl-dev
ARG LNTOP_SRC_PATH
WORKDIR /root/_build
# we want to populate the module cache based on the go.{mod,sum} files.
COPY "$LNTOP_SRC_PATH/go.mod" .
COPY "$LNTOP_SRC_PATH/go.sum" .
# pre-cache deps
# see https://container-solutions.com/faster-builds-in-docker-with-go-1-11/
RUN go mod download
WORKDIR $GOPATH/src/github.com/edouardparis/lntop
COPY "$LNTOP_SRC_PATH" .
ENV GO111MODULE=on
RUN go install ./...
# ---------------------------------------------------------------------------------------------------------------------------
FROM golang:1.12-alpine as final
RUN apk add --no-cache \
bash fish \
ca-certificates \
tini
ENV PATH $PATH:/root
ARG LNTOP_CONF_PATH
# copy the binaries and entrypoint from the builder image.
COPY --from=builder /go/bin/lntop /bin/
WORKDIR /root
COPY "home" .
RUN mkdir ".lntop"
COPY "$LNTOP_CONF_PATH" ".lntop/"

@ -0,0 +1,14 @@
[logger]
type = "development" # "production"
dest = "/root/.lntop/lntop.log"
[network]
name = "lnd"
type = "lnd"
address = "//127.0.0.1:10009"
cert = "/root/.lnd/tls.cert"
macaroon = "/root/.lnd/data/chain/bitcoin/mainnet/admin.macaroon"
macaroon_timeout = 60
max_msg_recv_size = 52428800
conn_timeout = 1000000
pool_capacity = 3

@ -0,0 +1,11 @@
#!/usr/bin/env bash
set -e -o pipefail
if [[ ! $# -eq 0 ]]; then
exec "$@"
fi
echo "this docker-compose service is not designed to be launched via docker-compose up"
echo "exec lntop via ./lntop.sh or directly via docker, e.g. \`docker exec -ti lntop lntop\`"
exit 1

@ -0,0 +1,7 @@
#!/usr/bin/env bash
set -e -o pipefail
LND_HOME=${LND_HOME:?required}
exec docker exec lntop tail /root/.lntop/lntop.log "$@"
Loading…
Cancel
Save