Merge branch 'release/v1' of pablo/counterweight_v2 into master

This commit is contained in:
pablo 2023-02-19 18:19:08 +00:00 committed by Gogs
commit 5f8706c084
6 changed files with 145 additions and 9 deletions

View file

@ -1,3 +1,5 @@
SUBNET=<SUBNET>
GATEWAY=<GATEWAY>
BITCOIN_IP_ADDRESS=<BITCOIN_IP_ADDRESS>
ELECTRS_IP_ADDRESS=<ELECTRS_IP_ADDRESS>

95
README.md Normal file
View file

@ -0,0 +1,95 @@
# Counterweight V2
Release: v1
This is the repo where I store everything necessary to spin up my
Bitcoin-related node.
It currently includes:
- Bitcoin core
- electrs
- mempool block explorer
- lnbits
## How to deploy
### Requirements
These instructions assume you are on a debian/ubuntu machine with docker,
docker compose and git installed.
### Cloning
First, clone this repo where you would like to run your node.
### Building electrs
Since there is no good `electrs` docker image out there, we roll our own one
for this project. The file is `electrs-docker/Dockerfile`. To build the image,
run the following command:
```bash
cd electrs-docker
docker build -t my-electrs:latest -f Dockerfile .
```
### Environment and configuration files
Now, you need to build a `.env` file. You can start by making a copy of
`.env-example` and filling it.
Afterwards, create the `data` folder in the root of the cloned repo. Inside,
create the folders `bitcoin`, `electrs`, `mempool` and `lnbits`.
Inside `data/bitcoin`, you will need to place a `bitcoin.conf` file. You can
use the example in `config_templates/bitcoin.conf`. Ensure that your inputs
here are consistent with the ones in the `.env` file.
Inside `data/electrs/config`, you will need to place a `config.toml` file. You
can use the example in `config_templates/config.toml`. For this one, you should
not make any changes if you are following these instructions.
Inside `data/lnbits`, you will need to place a `.env` file. Pay attention: this
file is specific for LNbits and is unrelated to the other `.env` file that sits
on the root of this repo. The best place to get an example
is [the official LNbits repository](https://github.com/lnbits/lnbits).
### Running and Smoke testing
To run, execute a simple `docker compose up -d`.
Once you get everything running, here is how you can check on the health of the
different services:
- All: check if the containers are running.
- Bitcoin: check the logs. You should see Bitcoin updating its tip with as new
blocks are found.
- Electrs: connect from Sparrow or another wallet.
- Mempool: visit the page.
- LNbits: visit the page, perhaps make a small transaction if you want to be
dead sure everything is up and running.
### Monitoring
TODO: explain how to setup automatic monitoring of all the services
## Upgrading versions of the different services
- Bitcoin: upgrade in docker-compose.yaml.
- electrs: specify tag in the `git checkout` command in the custom electrs
dockerfile, build again.
- mempool: upgrade web, api and db in docker-compose.yaml.
- LNbits: upgrade in docker-compose.yaml.
## How to backup data
The relevant assets you should backup are:
- Your `.env` file.
- Your `docker-compose-yaml` (if you changed any of its contents).
- Your data folder.
An `rsync` to another server should do the trick. You probably don't want to
copy the bitcoin blockchain and the electrs indexes due to their massive size.
You can use the `--exclude` option when calling `rsync` to exclude them.

View file

@ -0,0 +1,18 @@
# [core]
# Maintain a full transaction index, used by the getrawtransaction rpc call.
txindex=1
# [rpc]
# Accept command line and JSON-RPC commands.
server=1
rpcauth=<fill your user here>:<fill the password hash here> # You can use https://jlopp.github.io/bitcoin-core-rpc-auth-generator/ to generate this.
rpcallowip=<allowed ips> # You probably want to put the subnet mask used in the docker-compose.yaml .env file here.
rpcbind=0.0.0.0
# [wallet]
# Do not load the wallet and disable wallet RPC calls.
disablewallet=1
pruned=0
peerbloomfilters=1

View file

@ -0,0 +1,21 @@
# File where bitcoind stores the cookie, usually file .cookie in its datadir
cookie_file = "/home/bitcoin/data/.cookie"
# The listening RPC address of bitcoind, port is usually 8332
daemon_rpc_addr = "bitcoind:8332"
# The listening P2P address of bitcoind, port is usually 8333
daemon_p2p_addr = "bitcoind:8333"
# Directory where the index should be stored. It should have at least 70GB of free space.
db_dir = "/home/electrs/data/index"
# bitcoin means mainnet. Don't set to anything else unless you're a developer.
network = "bitcoin"
# The address on which electrs should listen. Warning: 0.0.0.0 is probably a bad idea!
# Tunneling is the recommended way to access electrs remotely.
electrum_rpc_addr = "0.0.0.0:50001"
# How much information about internal workings should electrs print. Increase before reporting a bug.
log_filters = "INFO"

View file

@ -2,7 +2,7 @@ version: '3'
services:
bitcoin:
container_name: bitcoind
image: lncm/bitcoind:v22.0
image: lncm/bitcoind:v22.0@sha256:0e00667f8f084536f45ba680844b6f23a51d3101fb08d8e0ca371ee3f89bc72d
volumes:
- ./data/bitcoin:/data/.bitcoin
restart: unless-stopped
@ -37,7 +37,7 @@ services:
FRONTEND_HTTP_PORT: "8080"
BACKEND_MAINNET_HTTP_HOST: "mempool-api"
depends_on: [mempool-api]
image: mempool/frontend:latest
image: mempool/frontend:v2.4.0@sha256:cac0536d7663c2c9364ae015951c3493c6b0f566ee17eacccdaa41d55d31d86f
user: "1000:1000"
restart: on-failure
stop_grace_period: 1m
@ -65,7 +65,7 @@ services:
DATABASE_PASSWORD: ${MEMPOOL_MYSQL_PASSWORD}
STATISTICS_ENABLED: "true"
depends_on: [mempool-db]
image: mempool/backend:latest
image: mempool/backend:v2.4.1@sha256:2fb4e74fc1871535da2f57364b931038a927fbc390793bfc10a60a7b8f91c79d
user: "1000:1000"
restart: on-failure
stop_grace_period: 1m
@ -83,7 +83,7 @@ services:
MYSQL_PASSWORD: ${MEMPOOL_MYSQL_PASSWORD}
MYSQL_ROOT_PASSWORD: ${MEMPOOL_MYSQL_ROOT_PASSWORD}
depends_on: [bitcoin, electrs]
image: mariadb:10.5.8
image: mariadb:10.5.8@sha256:03fb19fa5729856ec8c8ed23d421ed1ab6c0e2d63fdf2b1bd8d311025e228a9b
user: "1000:1000"
restart: on-failure
stop_grace_period: 1m
@ -94,7 +94,7 @@ services:
lnbits:
container_name: lnbits
image: lnbitsdocker/lnbits-legend:0.9.7
image: lnbitsdocker/lnbits-legend:0.9.7@sha256:dfc8bc738c6e288f33579888a95576cb603db48442609a1b2bda42f46d9a7ed4
volumes:
- ./data/lnbits/.env:/app/.env
- ./data/lnbits/data/:/app/data
@ -111,5 +111,5 @@ networks:
driver: bridge
ipam:
config:
- subnet: 10.5.0.0/16
gateway: 10.5.0.1
- subnet: ${SUBNET}
gateway: ${GATEWAY}

View file

@ -1,4 +1,3 @@
FROM debian:bullseye
RUN apt update
@ -12,6 +11,7 @@ RUN apt install -y \
RUN git clone https://github.com/romanz/electrs
WORKDIR electrs
RUN git checkout v0.9.11
RUN ls -la
RUN cargo build --locked --release