mirror of
https://github.com/benjamin-wilson/public-pool.git
synced 2025-03-17 13:21:43 +01:00
Adds a full setup (bitcoin core + public-pool) (#10)
* full setup bitcoin + public-pool for docker
This commit is contained in:
parent
3ed6b8f5c4
commit
eef8978250
@ -3,4 +3,5 @@ README.md
|
||||
LICENSE.txt
|
||||
Dockerfile
|
||||
.vscode
|
||||
.gitignore
|
||||
.gitignore
|
||||
full-setup/
|
||||
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -38,6 +38,7 @@ settings.json
|
||||
|
||||
#DB
|
||||
**.sqlite**
|
||||
./full-setup/data/*
|
||||
|
||||
#https
|
||||
**.pem
|
@ -24,6 +24,6 @@ EXPOSE 8332
|
||||
WORKDIR /public-pool
|
||||
|
||||
COPY --from=build /build .
|
||||
COPY .env.example .env
|
||||
#COPY .env.example .env
|
||||
|
||||
CMD ["/usr/local/bin/node", "dist/main"]
|
||||
|
@ -86,4 +86,4 @@ The docker-compose binds to `127.0.0.1` by default. To expose the Stratum servic
|
||||
rpcallowip=172.16.0.0/12
|
||||
```
|
||||
|
||||
to your bitcoin.conf.
|
||||
to your bitcoin.conf.
|
||||
|
66
full-setup/README.md
Normal file
66
full-setup/README.md
Normal file
@ -0,0 +1,66 @@
|
||||
# Full Setup for public pool
|
||||
|
||||
This setup provides a docker-compose setup consisting of Bitcoin Core Node and Public-Pool running in Mainnet or Testnet.
|
||||
|
||||
It exposes following ports:
|
||||
|
||||
- `8332/18332` Bitcoin RPC on `localhost`
|
||||
- `8333/18333` Bitcoin peering on `0.0.0.0`
|
||||
- `3333/13333` Public-Pool Stratum port on `0.0.0.0`
|
||||
- `3334/13334` Public-Pool API port on `localhost`
|
||||
|
||||
The docker-compose setups for Mainnet and Testnet can be run in parallel without any problems.
|
||||
|
||||
# Building Images
|
||||
|
||||
The images are built with
|
||||
|
||||
```
|
||||
docker compose -f docker-compose-mainnet.yml build
|
||||
```
|
||||
|
||||
Instead of `-mainnet` you can use `-testnet` for Testnet
|
||||
|
||||
# Preparing directories
|
||||
|
||||
Before starting the setup, directories need to be created.
|
||||
|
||||
```
|
||||
sudo ./prepare.sh
|
||||
```
|
||||
|
||||
# Config files
|
||||
|
||||
There are 4 config files for Mainnet and Testnet
|
||||
|
||||
`mainnet`:
|
||||
- `public-pool-mainnet.env`
|
||||
- `bitcoin-mainnet.conf`
|
||||
|
||||
`testnet`:
|
||||
- `public-pool-testnet.env`
|
||||
- `bitcoin-testnet.conf`
|
||||
|
||||
**note: pruning (`prune=550`) is enabled by default in the config**
|
||||
# Running the setup
|
||||
|
||||
To start the setup in foreground mode:
|
||||
|
||||
```
|
||||
docker compose -f docker-compose-mainnet.yml up
|
||||
```
|
||||
|
||||
To run the setup in detached / background mode use `up -d`.
|
||||
|
||||
In detached mode logs can be watched with:
|
||||
```
|
||||
docker compose -f docker-compose-mainnet.yml logs --tail 100 -f
|
||||
```
|
||||
|
||||
# Stopping the setup
|
||||
|
||||
To stop the setup use:
|
||||
|
||||
```
|
||||
docker compose -f docker-compose-mainnet.yml down
|
||||
```
|
28
full-setup/bitcoin-mainnet.conf
Normal file
28
full-setup/bitcoin-mainnet.conf
Normal file
@ -0,0 +1,28 @@
|
||||
# condensed bitcoin config
|
||||
|
||||
# pruning setting
|
||||
prune=550
|
||||
|
||||
# allow docker IPs
|
||||
rpcallowip=172.16.0.0/12
|
||||
rpcallowip=127.0.0.1
|
||||
|
||||
# bind docker container to 0.0.0.0:8332
|
||||
rpcbind=0.0.0.0
|
||||
rpcport=8332
|
||||
|
||||
# rpc user and password
|
||||
rpcpassword=bitcoin
|
||||
rpcuser=bitcoin
|
||||
|
||||
# enable server
|
||||
server=1
|
||||
|
||||
[main]
|
||||
[test]
|
||||
rpcbind=0.0.0.0
|
||||
rpcport=18332
|
||||
# no additional testnet settings
|
||||
|
||||
[signet]
|
||||
[regtest]
|
28
full-setup/bitcoin-testnet.conf
Normal file
28
full-setup/bitcoin-testnet.conf
Normal file
@ -0,0 +1,28 @@
|
||||
# condensed bitcoin config
|
||||
|
||||
# pruning setting
|
||||
prune=550
|
||||
|
||||
# allow docker IPs
|
||||
rpcallowip=172.16.0.0/12
|
||||
rpcallowip=127.0.0.1
|
||||
|
||||
# bind docker container to 0.0.0.0:8332
|
||||
rpcbind=0.0.0.0
|
||||
rpcport=8332
|
||||
|
||||
# rpc user and password
|
||||
rpcpassword=bitcoin
|
||||
rpcuser=bitcoin
|
||||
|
||||
# enable server
|
||||
server=1
|
||||
|
||||
[main]
|
||||
[test]
|
||||
rpcbind=0.0.0.0
|
||||
rpcport=18332
|
||||
# no additional testnet settings
|
||||
|
||||
[signet]
|
||||
[regtest]
|
42
full-setup/docker-compose-mainnet.yml
Normal file
42
full-setup/docker-compose-mainnet.yml
Normal file
@ -0,0 +1,42 @@
|
||||
version: '3.8'
|
||||
|
||||
services:
|
||||
bitcoin:
|
||||
container_name: bitcoin
|
||||
build:
|
||||
context: ./docker/bitcoin
|
||||
dockerfile: Dockerfile
|
||||
restart: unless-stopped
|
||||
stop_grace_period: 30s
|
||||
networks:
|
||||
- bitcoin
|
||||
ports:
|
||||
- "127.0.0.1:8332:8332/tcp"
|
||||
- "0.0.0.0:8333:8333/tcp"
|
||||
command: >
|
||||
-printtoconsole
|
||||
-datadir=/app/data
|
||||
volumes:
|
||||
- "./data/mainnet/bitcoin:/app/data"
|
||||
- "./bitcoin-mainnet.conf:/app/data/bitcoin.conf:ro"
|
||||
|
||||
public-pool:
|
||||
container_name: public-pool
|
||||
build:
|
||||
context: ..
|
||||
dockerfile: Dockerfile
|
||||
restart: unless-stopped
|
||||
stop_grace_period: 30s
|
||||
networks:
|
||||
- bitcoin
|
||||
ports:
|
||||
- "0.0.0.0:3333:3333/tcp"
|
||||
- "127.0.0.1:3334:3334/tcp"
|
||||
volumes:
|
||||
- "./data/mainnet/public-pool:/public-pool/DB"
|
||||
- "./public-pool-mainnet.env:/public-pool/.env:ro"
|
||||
environment:
|
||||
- NODE_ENV=production
|
||||
|
||||
networks:
|
||||
bitcoin:
|
43
full-setup/docker-compose-testnet.yml
Normal file
43
full-setup/docker-compose-testnet.yml
Normal file
@ -0,0 +1,43 @@
|
||||
version: '3.8'
|
||||
|
||||
services:
|
||||
bitcoin-testnet:
|
||||
container_name: bitcoin-testnet
|
||||
build:
|
||||
context: ./docker/bitcoin
|
||||
dockerfile: Dockerfile
|
||||
restart: unless-stopped
|
||||
stop_grace_period: 30s
|
||||
networks:
|
||||
- bitcoin-testnet
|
||||
ports:
|
||||
- "127.0.0.1:18332:18332/tcp"
|
||||
- "0.0.0.0:18333:18333/tcp"
|
||||
command: >
|
||||
-printtoconsole
|
||||
-datadir=/app/data
|
||||
-testnet
|
||||
volumes:
|
||||
- "./data/testnet/bitcoin:/app/data"
|
||||
- "./bitcoin-testnet.conf:/app/data/bitcoin.conf:ro"
|
||||
|
||||
public-pool-testnet:
|
||||
container_name: public-pool-testnet
|
||||
build:
|
||||
context: ..
|
||||
dockerfile: Dockerfile
|
||||
restart: unless-stopped
|
||||
stop_grace_period: 30s
|
||||
networks:
|
||||
- bitcoin-testnet
|
||||
ports:
|
||||
- "0.0.0.0:13333:13333/tcp"
|
||||
- "127.0.0.1:13334:13334/tcp"
|
||||
volumes:
|
||||
- "./data/testnet/public-pool:/public-pool/DB"
|
||||
- "./public-pool-testnet.env:/public-pool/.env:ro"
|
||||
environment:
|
||||
- NODE_ENV=production
|
||||
|
||||
networks:
|
||||
bitcoin-testnet:
|
38
full-setup/docker/bitcoin/Dockerfile
Normal file
38
full-setup/docker/bitcoin/Dockerfile
Normal file
@ -0,0 +1,38 @@
|
||||
# Use an official Ubuntu as a parent image
|
||||
FROM ubuntu:22.04 AS build
|
||||
|
||||
ARG BITCOIN_CORE_VER=25.1
|
||||
|
||||
# Install Bitcoin Core
|
||||
RUN apt-get update && \
|
||||
apt-get install -y curl wget tar
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# download and extract bitcoin core
|
||||
RUN wget https://bitcoincore.org/bin/bitcoin-core-${BITCOIN_CORE_VER}/bitcoin-${BITCOIN_CORE_VER}-x86_64-linux-gnu.tar.gz -O - | tar xzv --strip-components=1
|
||||
|
||||
RUN pwd
|
||||
RUN find -ls
|
||||
|
||||
# use nonroot container
|
||||
FROM gcr.io/distroless/cc-debian11:nonroot
|
||||
|
||||
# Copy the app dir into distroless image
|
||||
COPY --chown=1000:1000 --from=build /app /app
|
||||
|
||||
# Expose port 8332/18332 for RPC and 8333/18333 for peer connections
|
||||
EXPOSE 8332 8333
|
||||
EXPOSE 18332 18333
|
||||
|
||||
# Run bitcoind by default when the container starts.
|
||||
ENTRYPOINT ["/app/bin/bitcoind"]
|
||||
|
||||
# use user with 1000:1000 for simplicity of ownerships
|
||||
# because it's the default UID:GID on debian and Ubuntu and derivatives
|
||||
USER 1000:1000
|
||||
|
||||
# Additional arguments can be passed to bitcoind via CMD
|
||||
# For example, to run in testnet mode, use docker run with the argument `-testnet`
|
||||
CMD ["-printtoconsole", "-datadir=/app/data"]
|
||||
|
5
full-setup/prepare.sh
Executable file
5
full-setup/prepare.sh
Executable file
@ -0,0 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
mkdir -p data/{mainnet,testnet}/bitcoin
|
||||
mkdir -p data/{mainnet,testnet}/public-pool
|
||||
|
34
full-setup/public-pool-mainnet.env
Normal file
34
full-setup/public-pool-mainnet.env
Normal file
@ -0,0 +1,34 @@
|
||||
BITCOIN_RPC_URL=http://bitcoin
|
||||
BITCOIN_RPC_USER=bitcoin
|
||||
BITCOIN_RPC_PASSWORD=bitcoin
|
||||
BITCOIN_RPC_PORT=8332
|
||||
BITCOIN_RPC_TIMEOUT=10000
|
||||
|
||||
# Enable in bitcoin.conf with
|
||||
# zmqpubrawblock=tcp://*:3000
|
||||
# BITCOIN_ZMQ_HOST="tcp://192.168.1.100:3000"
|
||||
|
||||
API_PORT=3334
|
||||
STRATUM_PORT=3333
|
||||
|
||||
#optional telegram bot
|
||||
#TELEGRAM_BOT_TOKEN=
|
||||
|
||||
#optional discord bot
|
||||
#DISCORD_BOT_CLIENTID=
|
||||
#DISCORD_BOT_GUILD_ID=
|
||||
#DISCORD_BOT_CHANNEL_ID=
|
||||
|
||||
#optional
|
||||
DEV_FEE_ADDRESS=
|
||||
# mainnet | testnet
|
||||
NETWORK=mainnet
|
||||
|
||||
API_SECURE=false
|
||||
|
||||
ENABLE_SOLO=true
|
||||
ENABLE_PROXY=false
|
||||
|
||||
BRAIINS_ACCESS_TOKEN=
|
||||
|
||||
PROXY_PORT=3333
|
34
full-setup/public-pool-testnet.env
Normal file
34
full-setup/public-pool-testnet.env
Normal file
@ -0,0 +1,34 @@
|
||||
BITCOIN_RPC_URL=http://bitcoin-testnet
|
||||
BITCOIN_RPC_USER=bitcoin
|
||||
BITCOIN_RPC_PASSWORD=bitcoin
|
||||
BITCOIN_RPC_PORT=18332
|
||||
BITCOIN_RPC_TIMEOUT=10000
|
||||
|
||||
# Enable in bitcoin.conf with
|
||||
# zmqpubrawblock=tcp://*:3000
|
||||
# BITCOIN_ZMQ_HOST="tcp://192.168.1.100:3000"
|
||||
|
||||
API_PORT=13334
|
||||
STRATUM_PORT=13333
|
||||
|
||||
#optional telegram bot
|
||||
#TELEGRAM_BOT_TOKEN=
|
||||
|
||||
#optional discord bot
|
||||
#DISCORD_BOT_CLIENTID=
|
||||
#DISCORD_BOT_GUILD_ID=
|
||||
#DISCORD_BOT_CHANNEL_ID=
|
||||
|
||||
#optional
|
||||
DEV_FEE_ADDRESS=
|
||||
# mainnet | testnet
|
||||
NETWORK=testnet
|
||||
|
||||
API_SECURE=false
|
||||
|
||||
ENABLE_SOLO=true
|
||||
ENABLE_PROXY=false
|
||||
|
||||
BRAIINS_ACCESS_TOKEN=
|
||||
|
||||
PROXY_PORT=3333
|
@ -622,4 +622,4 @@ export class StratumV1Client {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user