docker: enable docker-compose up command for btc and ltc compose files

This commit is contained in:
yancy ribbens 2019-02-25 07:45:47 -06:00 committed by yancy
parent 883f9e5f9a
commit 1f457ac1a8
5 changed files with 81 additions and 88 deletions

@ -68,7 +68,7 @@ docker volume create simnet_lnd_alice
docker volume create simnet_lnd_bob docker volume create simnet_lnd_bob
# Run the "Alice" container and log into it: # Run the "Alice" container and log into it:
$ docker-compose run -d --name alice --volume simnet_lnd_alice:/root/.lnd lnd_btc $ docker-compose run -d --name alice --volume simnet_lnd_alice:/root/.lnd lnd
$ docker exec -i -t alice bash $ docker exec -i -t alice bash
# Generate a new backward compatible nested p2sh address for Alice: # Generate a new backward compatible nested p2sh address for Alice:
@ -79,10 +79,10 @@ $ MINING_ADDRESS=<alice_address> docker-compose up -d btcd
# Generate 400 blocks (we need at least "100 >=" blocks because of coinbase # Generate 400 blocks (we need at least "100 >=" blocks because of coinbase
# block maturity and "300 ~=" in order to activate segwit): # block maturity and "300 ~=" in order to activate segwit):
$ docker-compose run btcctl generate 400 $ docker exec -it btcd /start-btcctl.sh generate 400
# Check that segwit is active: # Check that segwit is active:
$ docker-compose run btcctl getblockchaininfo | grep -A 1 segwit $ docker exec -it btcd /start-btcctl.sh getblockchaininfo | grep -A 1 segwit
``` ```
Check `Alice` balance: Check `Alice` balance:
@ -94,7 +94,7 @@ Connect `Bob` node to `Alice` node.
```bash ```bash
# Run "Bob" node and log into it: # Run "Bob" node and log into it:
$ docker-compose run -d --name bob --volume simnet_lnd_bob:/root/.lnd lnd_btc $ docker-compose run -d --name bob --volume simnet_lnd_bob:/root/.lnd lnd
$ docker exec -i -t bob bash $ docker exec -i -t bob bash
# Get the identity pubkey of "Bob" node: # Get the identity pubkey of "Bob" node:
@ -163,7 +163,7 @@ Create the `Alice<->Bob` channel.
alice$ lncli --network=simnet openchannel --node_key=<bob_identity_pubkey> --local_amt=1000000 alice$ lncli --network=simnet openchannel --node_key=<bob_identity_pubkey> --local_amt=1000000
# Include funding transaction in block thereby opening the channel: # Include funding transaction in block thereby opening the channel:
$ docker-compose run btcctl generate 3 $ docker exec -it btcd /start-btcctl.sh generate 3
# Check that channel with "Bob" was opened: # Check that channel with "Bob" was opened:
alice$ lncli --network=simnet listchannels alice$ lncli --network=simnet listchannels
@ -247,7 +247,7 @@ alice$ lncli --network=simnet listchannels
alice$ lncli --network=simnet closechannel --funding_txid=<funding_txid> --output_index=<output_index> alice$ lncli --network=simnet closechannel --funding_txid=<funding_txid> --output_index=<output_index>
# Include close transaction in a block thereby closing the channel: # Include close transaction in a block thereby closing the channel:
$ docker-compose run btcctl generate 3 $ docker exec -it btcd /start-btcctl.sh generate 3
# Check "Alice" on-chain balance was credited by her settled amount in the channel: # Check "Alice" on-chain balance was credited by her settled amount in the channel:
alice$ lncli --network=simnet walletbalance alice$ lncli --network=simnet walletbalance
@ -299,10 +299,7 @@ First of all you need to run `btcd` node in `testnet` and wait for it to be
synced with test network (`May the Force and Patience be with you`). synced with test network (`May the Force and Patience be with you`).
```bash ```bash
# Init bitcoin network env variable: # Init bitcoin network env variable:
$ export NETWORK="testnet" $ NETWORK="testnet" docker-compose up
# Run "btcd" node:
$ docker-compose up -d "btcd"
``` ```
After `btcd` synced, connect `Alice` to the `Faucet` node. After `btcd` synced, connect `Alice` to the `Faucet` node.

@ -52,7 +52,7 @@ PARAMS=$(echo $PARAMS \
"--rpccert=/rpc/rpc.cert" \ "--rpccert=/rpc/rpc.cert" \
"--rpcuser=$RPCUSER" \ "--rpcuser=$RPCUSER" \
"--rpcpass=$RPCPASS" \ "--rpcpass=$RPCPASS" \
"--rpcserver=rpcserver" \ "--rpcserver=localhost" \
) )
PARAMS="$PARAMS $@" PARAMS="$PARAMS $@"

@ -0,0 +1,55 @@
version: '2'
services:
# ltc is an image of litecoin node which used as base image for ltcd and
# ltcctl. The environment variables default values determined on stage of
# container start within starting script.
ltcd:
image: ltcd
container_name: ltcd
build:
context: ltcd/
volumes:
- shared:/rpc
- litecoin:/data
environment:
- RPCUSER
- RPCPASS
- NETWORK
- DEBUG
- MINING_ADDRESS
entrypoint: ["./start-ltcd.sh"]
lnd:
image: lnd
container_name: lnd_ltc
build:
context: ../
dockerfile: docker/lnd/Dockerfile
environment:
- RPCUSER
- RPCPASS
- NETWORK
- CHAIN
- DEBUG
volumes:
- shared:/rpc
- lnd_ltc:/root/.lnd
entrypoint: ["./start-lnd.sh"]
links:
- "ltcd:blockchain"
volumes:
# shared volume is need to store the btcd rpc certificates and use it within
# ltcctl and lnd containers.
shared:
driver: local
# litecoin volume is needed for maintaining blockchain persistence
# during ltcd container recreation.
litecoin:
driver: local
# lnd volume is used for persisting lnd application data and chain state
# during container lifecycle.
lnd_ltc:
driver: local

@ -1,11 +1,11 @@
version: '2' version: '2'
services: services:
# btc is an image of bitcoin node which used as base image for btcd and # btc is an image of bitcoin node which used as base image for btcd and
# btccli. The environment variables default values determined on stage of # btccli. The environment variables default values determined on stage of
# container start within starting script. # container start within starting script.
btc: btcd:
image: btcd image: btcd
container_name: btcd
build: build:
context: btcd/ context: btcd/
volumes: volumes:
@ -15,82 +15,28 @@ services:
- RPCUSER - RPCUSER
- RPCPASS - RPCPASS
- NETWORK - NETWORK
- DEBUG
- MINING_ADDRESS
entrypoint: ["./start-btcd.sh"]
btcd: lnd:
extends: btc image: lnd
container_name: btcd container_name: lnd
environment:
- DEBUG
- MINING_ADDRESS
- NETWORK
entrypoint: ["./start-btcd.sh"]
btcctl:
extends: btc
container_name: btcctl
links:
- "btcd:rpcserver"
entrypoint: ["./start-btcctl.sh"]
# ltc is an image of litecoin node which used as base image for ltcd and
# ltcctl. The environment variables default values determined on stage of
# container start within starting script.
ltc:
image: ltcd
build: build:
context: ltcd/ context: ../
volumes: dockerfile: docker/lnd/Dockerfile
- shared:/rpc
- litecoin:/data
environment: environment:
- RPCUSER - RPCUSER
- RPCPASS - RPCPASS
- NETWORK - NETWORK
- CHAIN
ltcd: - DEBUG
extends: ltc volumes:
container_name: ltcd - shared:/rpc
environment: - lnd:/root/.lnd
- DEBUG entrypoint: ["./start-lnd.sh"]
- MINING_ADDRESS
- NETWORK
entrypoint: ["./start-ltcd.sh"]
ltcctl:
extends: ltc
container_name: ltcctl
links:
- "ltcd:rpcserver"
entrypoint: ["./start-ltcctl.sh"]
lnd:
image: lnd
build:
context: ../
dockerfile: docker/lnd/Dockerfile
environment:
- RPCUSER
- RPCPASS
- NETWORK
- CHAIN
- DEBUG
volumes:
- shared:/rpc
- lnd:/root/.lnd
entrypoint: ["./start-lnd.sh"]
lnd_ltc:
extends: lnd
container_name: lnd_ltc
links: links:
- "ltcd:blockchain" - "btcd:blockchain"
lnd_btc:
extends: lnd
container_name: lnd_btc
links:
- "btcd:blockchain"
volumes: volumes:
# shared volume is need to store the btcd rpc certificates and use it within # shared volume is need to store the btcd rpc certificates and use it within
@ -107,8 +53,3 @@ volumes:
# during container lifecycle. # during container lifecycle.
lnd: lnd:
driver: local driver: local
# litecoin volume is needed for maintaining blockchain persistence
# during ltcd container recreation.
litecoin:
driver: local

@ -52,7 +52,7 @@ PARAMS=$(echo $PARAMS \
"--rpccert=/rpc/rpc.cert" \ "--rpccert=/rpc/rpc.cert" \
"--rpcuser=$RPCUSER" \ "--rpcuser=$RPCUSER" \
"--rpcpass=$RPCPASS" \ "--rpcpass=$RPCPASS" \
"--rpcserver=rpcserver" \ "--rpcserver=localhost" \
) )
PARAMS="$PARAMS $@" PARAMS="$PARAMS $@"