docker: use readonly macaroon

This commit is contained in:
bitromortac 2023-12-31 10:09:14 +01:00
parent 2fb1b37803
commit 02f2923069
No known key found for this signature in database
GPG key ID: 1965063FC13BEBE2
5 changed files with 14 additions and 12 deletions

View file

@ -37,7 +37,7 @@ COPY --from=builder /root/.venv /root/.venv
ENV PATH="/root/.venv/bin:$PATH:/root"
ENV TLS_CERT_FILE /root/aux/tls.cert
ENV ADMIN_MACAROON_FILE /root/aux/admin.macaroon
ENV MACAROON_FILE /root/aux/readonly.macaroon
# copy sources under /root/lndmanage
WORKDIR /root/lndmanage

View file

@ -8,19 +8,21 @@ To run `lndmanage` from a docker container:
# so $HOME directory is /root
# build the container
./build.sh
./build.sh
# if you have local lnd node on host machine, point LND_HOME to your actual lnd directory:
export LND_HOME=~/.lnd
# or alternatively if you have remote lnd node, specify paths to auth files explicitly:
# export TLS_CERT_FILE=/path/to/tls.cert
# export ADMIN_MACAROON_FILE=/path/to/admin.macaroon
# export MACAROON_FILE=/path/to/readonly.macaroon
# export LND_GRPC_HOST=<remoteip>:10009
# note that in order to have all features available, you will need to create a
# custom macaroon, see `scripts/bakemacaroon.sh`
# look into _settings.sh for more details on container configuration
# run lndmanage from the container:
# run lndmanage from the container:
./lndmanage.sh status
# lndmanage cache will be mapped to host folder at ./_volumes/lndmanage-cache

View file

@ -1,22 +1,22 @@
#!/usr/bin/env bash
# you have two possible ways how to specify ADMIN_MACAROON_FILE and TLS_CERT_FILE
# you have two possible ways how to specify MACAROON_FILE and TLS_CERT_FILE
# 1. specify LND_HOME if it is located on your local machine, we use default paths from there
# 2. specify env variables ADMIN_MACAROON_FILE and TLS_CERT_FILE
# 2. specify env variables MACAROON_FILE and TLS_CERT_FILE
# also you want to specify LND_GRPC_HOST if your node is remote
# other config tweaks have to be done by changing lndmanage/home/config_template.ini
# note: docker uses network_mode: host
if [[ -z "$ADMIN_MACAROON_FILE" || -z "$TLS_CERT_FILE" ]]; then
if [[ -z "$MACAROON_FILE" || -z "$TLS_CERT_FILE" ]]; then
if [[ -z "$LND_HOME" ]]; then
export LND_HOME="$HOME/.lnd"
echo "warning: LND_HOME is not set, assuming '$LND_HOME'"
fi
fi
export ADMIN_MACAROON_FILE=${ADMIN_MACAROON_FILE:-$LND_HOME/data/chain/bitcoin/mainnet/admin.macaroon}
export MACAROON_FILE=${MACAROON_FILE:-$LND_HOME/data/chain/bitcoin/mainnet/readonly.macaroon}
export TLS_CERT_FILE=${TLS_CERT_FILE:-$LND_HOME/tls.cert}
export LND_GRPC_HOST=${LND_GRPC_HOST:-127.0.0.1:10009}

View file

@ -2,7 +2,7 @@
# see docker/build.sh
lnd_grpc_host = ${LND_GRPC_HOST}
tls_cert_file = ${TLS_CERT_FILE}
admin_macaroon_file = ${ADMIN_MACAROON_FILE}
macaroon_file = ${MACAROON_FILE}
[logging]
loglevel = INFO

View file

@ -20,9 +20,9 @@ if [[ ! -e "$LNDMANAGE_AUX_DIR" ]]; then
fi
LNDMANAGE_AUX_DIR_ABSOLUTE=$(abs_path "$LNDMANAGE_AUX_DIR")
# we use LNDMANAGE_AUX_DIR as ad-hoc volume to pass admin.macaroon and tls.cert into our container
# we use LNDMANAGE_AUX_DIR as ad-hoc volume to pass readonly.macaroon and tls.cert into our container
# it is mapped to /root/aux, config_template.ini assumes that
cp "$ADMIN_MACAROON_FILE" "$LNDMANAGE_AUX_DIR/admin.macaroon"
cp "$MACAROON_FILE" "$LNDMANAGE_AUX_DIR/readonly.macaroon"
cp "$TLS_CERT_FILE" "$LNDMANAGE_AUX_DIR/tls.cert"
if [[ -n "$LNDMANAGE_VERBOSE" ]]; then
@ -36,7 +36,7 @@ exec docker run \
-v "$LNDMANAGE_AUX_DIR_ABSOLUTE:/root/aux" \
-e "LND_GRPC_HOST=${LND_GRPC_HOST}" \
-e "TLS_CERT_FILE=/root/aux/tls.cert" \
-e "ADMIN_MACAROON_FILE=/root/aux/admin.macaroon" \
-e "MACAROON_FILE=/root/aux/readonly.macaroon" \
-ti \
lndmanage:local \
run-lndmanage "$@"