From 5f9c32cb7eba29a15641209b76f300623df4e21e Mon Sep 17 00:00:00 2001 From: pablo Date: Sat, 18 Feb 2023 19:24:33 +0100 Subject: [PATCH 01/11] Moved hardcodes from docker compose to .env --- .env-example | 2 ++ docker-compose.yaml | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.env-example b/.env-example index 910dda2..e8ec4c5 100644 --- a/.env-example +++ b/.env-example @@ -1,3 +1,5 @@ +SUBNET= +GATEWAY= BITCOIN_IP_ADDRESS= ELECTRS_IP_ADDRESS= diff --git a/docker-compose.yaml b/docker-compose.yaml index 1f2384f..3a39397 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -111,5 +111,5 @@ networks: driver: bridge ipam: config: - - subnet: 10.5.0.0/16 - gateway: 10.5.0.1 + - subnet: ${SUBNET} + gateway: ${GATEWAY} From 1750edcc3d165af669480e250ec91fbc315f129c Mon Sep 17 00:00:00 2001 From: pablo Date: Sat, 18 Feb 2023 19:25:36 +0100 Subject: [PATCH 02/11] Formatting of Dockerfile. --- my-electrs-repo/Dockerfile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/my-electrs-repo/Dockerfile b/my-electrs-repo/Dockerfile index 19b1477..4e344aa 100644 --- a/my-electrs-repo/Dockerfile +++ b/my-electrs-repo/Dockerfile @@ -1,4 +1,3 @@ - FROM debian:bullseye RUN apt update @@ -15,4 +14,4 @@ WORKDIR electrs RUN ls -la RUN cargo build --locked --release -CMD target/release/electrs +CMD target/release/electrs \ No newline at end of file From 54f65efd778abbe8451bbe87a53775f85c12ec58 Mon Sep 17 00:00:00 2001 From: pablo Date: Sat, 18 Feb 2023 19:48:04 +0100 Subject: [PATCH 03/11] Improve readme, still WIP --- README.md | 65 +++++++++++++++++++++++++++++++++++ config_templates/bitcoin.conf | 18 ++++++++++ config_templates/config.toml | 21 +++++++++++ 3 files changed, 104 insertions(+) create mode 100644 README.md create mode 100644 config_templates/bitcoin.conf create mode 100644 config_templates/config.toml diff --git a/README.md b/README.md new file mode 100644 index 0000000..fbe6248 --- /dev/null +++ b/README.md @@ -0,0 +1,65 @@ +# Counterweight V2 + +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 + +TODO: explain + +### 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. TODO: make template in + + +### Smoke testing + +TODO: describe how to check that everything is warning. + +## Upgrading versions of the different services + +- Bitcoin: upgrade in docker-compose.yaml. +- electrs: specify tag in 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 + +TODO: explain how to back all the data up with a rsync. + + diff --git a/config_templates/bitcoin.conf b/config_templates/bitcoin.conf new file mode 100644 index 0000000..d5fccfb --- /dev/null +++ b/config_templates/bitcoin.conf @@ -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=: # You can use https://jlopp.github.io/bitcoin-core-rpc-auth-generator/ to generate this. +rpcallowip= # 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 diff --git a/config_templates/config.toml b/config_templates/config.toml new file mode 100644 index 0000000..3fce367 --- /dev/null +++ b/config_templates/config.toml @@ -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" From 65da55d636bc4e25b46d7554b1e0805be6441b11 Mon Sep 17 00:00:00 2001 From: pablo Date: Sat, 18 Feb 2023 22:58:26 +0100 Subject: [PATCH 04/11] . --- .../Dockerfile => Dockerfile-electrs | 1 + README.md | 27 ++++++++++++++++--- 2 files changed, 24 insertions(+), 4 deletions(-) rename my-electrs-repo/Dockerfile => Dockerfile-electrs (91%) diff --git a/my-electrs-repo/Dockerfile b/Dockerfile-electrs similarity index 91% rename from my-electrs-repo/Dockerfile rename to Dockerfile-electrs index 4e344aa..0d84d1e 100644 --- a/my-electrs-repo/Dockerfile +++ b/Dockerfile-electrs @@ -10,6 +10,7 @@ RUN apt install -y \ cargo RUN git clone https://github.com/romanz/electrs +RUN git checkout v0.9.10 WORKDIR electrs RUN ls -la RUN cargo build --locked --release diff --git a/README.md b/README.md index fbe6248..a027ec8 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,14 @@ First, clone this repo where you would like to run your node. ### Building electrs -TODO: explain +Since there is no good `electrs` docker image out there, we roll our own one +for this project. The file is `Dockerfile-electrs`. To build the image, run the +following command: + +```bash +docker build -t my-electrs:latest -f Dockerfile-electrs . +``` + ### Environment and configuration files @@ -43,12 +50,24 @@ 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. TODO: make template in +on the root of this repo. The best place to get an example is [the official +LNbits repository](https://github.com/lnbits/lnbits). -### Smoke testing +### Running and Smoke testing -TODO: describe how to check that everything is warning. +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. ## Upgrading versions of the different services From ca4a2c095a66d4caadc0965de7a0fe50ceadb657 Mon Sep 17 00:00:00 2001 From: pablo Date: Sat, 18 Feb 2023 23:02:14 +0100 Subject: [PATCH 05/11] stuff --- README.md | 5 +++-- Dockerfile-electrs => electrs-docker/Dockerfile | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) rename Dockerfile-electrs => electrs-docker/Dockerfile (100%) diff --git a/README.md b/README.md index a027ec8..b446056 100644 --- a/README.md +++ b/README.md @@ -24,11 +24,12 @@ 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 `Dockerfile-electrs`. To build the image, run the +for this project. The file is `electrs-docker/Dockerfile`. To build the image, run the following command: ```bash -docker build -t my-electrs:latest -f Dockerfile-electrs . +cd electrs-docker +docker build -t my-electrs:latest -f Dockerfile . ``` diff --git a/Dockerfile-electrs b/electrs-docker/Dockerfile similarity index 100% rename from Dockerfile-electrs rename to electrs-docker/Dockerfile index 0d84d1e..58b6559 100644 --- a/Dockerfile-electrs +++ b/electrs-docker/Dockerfile @@ -10,8 +10,8 @@ RUN apt install -y \ cargo RUN git clone https://github.com/romanz/electrs -RUN git checkout v0.9.10 WORKDIR electrs +RUN git checkout v0.9.10 RUN ls -la RUN cargo build --locked --release From 0483880f1f136bbb943c42c752d12aab2981a585 Mon Sep 17 00:00:00 2001 From: pablo Date: Sat, 18 Feb 2023 23:14:48 +0100 Subject: [PATCH 06/11] Specify versions --- README.md | 14 ++++++-------- docker-compose.yaml | 10 +++++----- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index b446056..8c9350d 100644 --- a/README.md +++ b/README.md @@ -24,15 +24,14 @@ 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: +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 @@ -51,9 +50,8 @@ 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). - +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 @@ -73,11 +71,11 @@ different services: ## Upgrading versions of the different services - Bitcoin: upgrade in docker-compose.yaml. -- electrs: specify tag in custom electrs dockerfile, build again. +- 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 TODO: explain how to back all the data up with a rsync. diff --git a/docker-compose.yaml b/docker-compose.yaml index 3a39397..86736c9 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -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 From 4514dc330913907ed6281fa7c6faa37af3a54e30 Mon Sep 17 00:00:00 2001 From: pablo Date: Sat, 18 Feb 2023 23:18:32 +0100 Subject: [PATCH 07/11] Electrs back to 0.9.11 --- electrs-docker/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/electrs-docker/Dockerfile b/electrs-docker/Dockerfile index 58b6559..e508ccf 100644 --- a/electrs-docker/Dockerfile +++ b/electrs-docker/Dockerfile @@ -11,7 +11,7 @@ RUN apt install -y \ RUN git clone https://github.com/romanz/electrs WORKDIR electrs -RUN git checkout v0.9.10 +RUN git checkout v0.9.11 RUN ls -la RUN cargo build --locked --release From db0d25b86e046a97a2063f880425d189bc3a0cee Mon Sep 17 00:00:00 2001 From: pablo Date: Sun, 19 Feb 2023 09:03:11 +0100 Subject: [PATCH 08/11] Document how to backup data. --- README.md | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 8c9350d..48243d7 100644 --- a/README.md +++ b/README.md @@ -76,8 +76,15 @@ different services: - mempool: upgrade web, api and db in docker-compose.yaml. - LNbits: upgrade in docker-compose.yaml. -### How to backup data +## How to backup data -TODO: explain how to back all the data up with a rsync. +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. From a03badb8e1663c2c3303da7514847d7b229f43ba Mon Sep 17 00:00:00 2001 From: pablo Date: Sun, 19 Feb 2023 09:03:16 +0100 Subject: [PATCH 09/11] Add stuff to backlog. --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index 48243d7..a2fc5f6 100644 --- a/README.md +++ b/README.md @@ -87,4 +87,10 @@ 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. +## Backlog + +- Add LND +- Add Thunderhub +- Add charge-lnd +- Add Lightning Terminal From bebd461769713d69f6f02825335ba5bcb86bfb20 Mon Sep 17 00:00:00 2001 From: pablo Date: Sun, 19 Feb 2023 09:04:00 +0100 Subject: [PATCH 10/11] Add todo. --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index a2fc5f6..10dee7a 100644 --- a/README.md +++ b/README.md @@ -68,6 +68,10 @@ different services: - 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. From 84c0a5036118f93cdb847cff392e8083ff34a2ac Mon Sep 17 00:00:00 2001 From: pablo Date: Sun, 19 Feb 2023 19:18:19 +0100 Subject: [PATCH 11/11] Update readme --- README.md | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 10dee7a..195fbbb 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # Counterweight V2 +Release: v1 + This is the repo where I store everything necessary to spin up my Bitcoin-related node. @@ -91,10 +93,3 @@ 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. -## Backlog - -- Add LND -- Add Thunderhub -- Add charge-lnd -- Add Lightning Terminal -