-
Notifications
You must be signed in to change notification settings - Fork 408
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add docker compose for one step setup with testnet #1000
base: master
Are you sure you want to change the base?
Changes from 5 commits
d50300a
8ce65df
62e6d2f
0de73a1
34fffe1
cec3576
b4cb156
3c40771
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
# Docker installation | ||
|
||
## Docker-based installation from source | ||
|
||
**Important**: The `Dockerfile` is provided for demonstration purposes and may | ||
NOT be suitable for production use. The maintainers of electrs are not deeply | ||
familiar with Docker, so you should DYOR. If you are not familiar with Docker | ||
either it's probably be safer to NOT use it. | ||
|
||
Note: currently Docker installation links statically | ||
|
||
Note: health check only works if Prometheus is running on port 4224 inside | ||
container | ||
|
||
```bash | ||
$ docker build -t electrs-app . | ||
$ mkdir db | ||
$ docker run --network host \ | ||
--volume $HOME/.bitcoin:/home/user/.bitcoin:ro \ | ||
--volume $PWD/db:/home/user/db \ | ||
--env ELECTRS_DB_DIR=/home/user/db \ | ||
--rm -i -t electrs-app | ||
``` | ||
|
||
If not using the host-network, you probably want to expose the ports for electrs | ||
and Prometheus like so: | ||
|
||
```bash | ||
$ docker run --volume $HOME/.bitcoin:/home/user/.bitcoin:ro \ | ||
--volume $PWD/db:/home/user/db \ | ||
--env ELECTRS_DB_DIR=/home/user/db \ | ||
--env ELECTRS_ELECTRUM_RPC_ADDR=0.0.0.0:50001 \ | ||
--env ELECTRS_MONITORING_ADDR=0.0.0.0:4224 \ | ||
--rm -i -t electrs-app | ||
``` | ||
|
||
To access the server from outside Docker, add `-p 50001:50001 -p 4224:4224` but | ||
be aware of the security risks. Good practice is to group containers that needs | ||
access to the server inside the same Docker network and not expose the ports to | ||
the outside world. | ||
|
||
## Docker compose, one step for installation | ||
|
||
**NOTE**: This is intend for one step setup with testnet/signet/regnet, inspired | ||
by [Polar](https://github.com/jamaljsr/polar). **NOT RECOMMAND WITH MAINNET** | ||
|
||
To setup testnet, just switch to the [docker](../docker/testnet), and then run: | ||
|
||
```bash | ||
docker compose up -d | ||
``` | ||
|
||
If you are not using Docker Desktop, run: | ||
|
||
```bash | ||
docker-compose up -d | ||
``` | ||
|
||
The default rpc auth info for bitcoin core is: `alice:alice`, if you want to | ||
change it, just create a new one with [rpcauth.py](https://github.com/bitcoin/bitcoin/tree/master/share/rpcauth) | ||
and replace both line 19 in `docker-compose.yml` and line 16 in `electrs.toml` | ||
with new generated auth info: | ||
|
||
``` | ||
-rpcauth=alice:128f22494cc2208ea8376a3d0b45a131$9cc0187c0e49f35454a3ed1250e40ecaef420cfcd294d3ac22496adbe64f04b9 | ||
``` | ||
|
||
Using it with bitcoin mainnet highly not recommand, use it with you own risk. | ||
It can not start properly with mainnet by default, you need to generated new rpc | ||
auth info and modify `docker-compose.yml` and `electrs.toml`. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Which chain you want to use. | ||
# Allowed values: 'bitcoin', 'testnet', 'regtest' or 'signet' | ||
network = "bitcoin" | ||
|
||
# The listening RPC address of bitcoind, | ||
# json-rpc-ports: | ||
# bitcoin: 8332 | ||
# testnet: 18332 | ||
# signnet: 38332 | ||
# regtest: 18443 | ||
daemon_rpc_addr = "bitcoind:8332" | ||
|
||
# Using cookie file to auth | ||
#cookie_file = "~/.bitcoin/.cookie" | ||
# Using rpc auth instead of cookie file | ||
auth = "<rpcauth-username>:<rpcauth-password>" | ||
|
||
# The listening P2P address of bitcoind | ||
# p2p-ports: | ||
# bitcoin: 8333 | ||
# testnet: 18333 | ||
# signnet: 38333 | ||
# regtest: 18444 | ||
daemon_p2p_addr = "bitcoind:8333" | ||
|
||
# Directory where the index should be stored. It should have at least 70GB of free space. | ||
db_dir = "/electrs/db" | ||
|
||
# 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 = "127.0.0.1:50001" | ||
|
||
# How much information about internal workings should electrs print. Increase before reporting a bug. | ||
log_filters = "INFO" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
version: "3" | ||
services: | ||
bitcoind: | ||
container_name: bitcoind | ||
privileged: true | ||
image: oneforalonee/bitcoind:v26.0 | ||
restart: on-failure | ||
hostname: bitcoind | ||
stop_grace_period: 5m | ||
environment: | ||
USERID: ${USERID:-1000} | ||
GROUPID: ${GROUPID:-1000} | ||
command: >- | ||
bitcoind -server=1 -chain=main | ||
-debug=1 -zmqpubrawblock=tcp://0.0.0.0:28332 | ||
-zmqpubrawtx=tcp://0.0.0.0:28333 -zmqpubhashblock=tcp://0.0.0.0:28334 | ||
-txindex=1 -dnsseed=0 -upnp=0 -rpcbind=0.0.0.0 -rpcallowip=0.0.0.0/0 | ||
-rpcport=8332 -rest -listen=1 -listenonion=0 | ||
expose: | ||
- 8332 | ||
ports: | ||
- 8332:8332 | ||
volumes: | ||
- ./bitcoind:/home/bitcoin/.bitcoin | ||
|
||
electrs: | ||
depends_on: | ||
- bitcoind | ||
links: | ||
- bitcoind | ||
container_name: electrs | ||
privileged: true | ||
image: oneforalonee/electrs:latest | ||
restart: on-failure | ||
hostname: electrs | ||
command: >- | ||
/usr/bin/electrs --conf=/electrs/electrs.toml | ||
expose: | ||
- 50001 | ||
ports: | ||
- 50001:50001 | ||
volumes: | ||
- ./electrs_db:/electrs/db | ||
- ./conf.toml:/electrs/electrs.toml |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Which chain you want to use. | ||
# Allowed values: 'bitcoin', 'testnet', 'regtest' or 'signet' | ||
network = "testnet" | ||
|
||
# The listening RPC address of bitcoind, | ||
# json-rpc-ports: | ||
# bitcoin: 8332 | ||
# testnet: 18332 | ||
# signnet: 38332 | ||
# regtest: 18443 | ||
daemon_rpc_addr = "bitcoind:18332" | ||
|
||
# Using cookie file to auth | ||
#cookie_file = "~/.bitcoin/.cookie" | ||
# Using rpc auth instead of cookie file | ||
auth = "alice:alice" | ||
|
||
# The listening P2P address of bitcoind | ||
# p2p-ports: | ||
# bitcoin: 8333 | ||
# testnet: 18333 | ||
# signnet: 38333 | ||
# regtest: 18444 | ||
daemon_p2p_addr = "bitcoind:18333" | ||
|
||
# Directory where the index should be stored. It should have at least 70GB of free space. | ||
db_dir = "/electrs/db" | ||
|
||
# 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:50002" | ||
|
||
# How much information about internal workings should electrs print. Increase before reporting a bug. | ||
log_filters = "INFO" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
version: "3" | ||
services: | ||
oneforalone marked this conversation as resolved.
Show resolved
Hide resolved
|
||
bitcoind: | ||
container_name: bitcoind | ||
privileged: true | ||
image: oneforalonee/bitcoind:v26.0 | ||
restart: on-failure | ||
hostname: bitcoind | ||
stop_grace_period: 5m | ||
environment: | ||
USERID: ${USERID:-1000} | ||
GROUPID: ${GROUPID:-1000} | ||
command: >- | ||
bitcoind -server=1 -testnet=1 | ||
-zmqpubrawblock=tcp://0.0.0.0:28334 | ||
-zmqpubrawtx=tcp://0.0.0.0:28335 -zmqpubhashblock=tcp://0.0.0.0:28336 | ||
-txindex=1 -rpcbind=0.0.0.0 -rpcallowip=0.0.0.0/0 | ||
-rpcport=18332 -rest -listen=1 -listenonion=0 | ||
-rpcauth=alice:128f22494cc2208ea8376a3d0b45a131$9cc0187c0e49f35454a3ed1250e40ecaef420cfcd294d3ac22496adbe64f04b9 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it possible to not use a constant There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm using this constant
But i thought it's kind complicate, most people just want one-click to use it. |
||
expose: | ||
- 18332 | ||
ports: | ||
- 18332:18332 | ||
volumes: | ||
- ./bitcoind:/home/bitcoin/.bitcoin | ||
|
||
electrs: | ||
depends_on: | ||
- bitcoind | ||
links: | ||
- bitcoind | ||
container_name: electrs | ||
privileged: true | ||
image: oneforalonee/electrs:latest | ||
restart: on-failure | ||
hostname: electrs | ||
command: >- | ||
/usr/bin/electrs --conf=/electrs/electrs.toml | ||
expose: | ||
- 50002 | ||
ports: | ||
- 50002:50002 | ||
volumes: | ||
- ./db:/electrs/db | ||
- ./conf.toml:/electrs/electrs.toml |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are those changes required?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, no, that's just my editor's auto-format plugin changed it while save the file. I'll remove this change, soon.