Jump to content

ElectrumX Server Setup Guide [Docker]


buzzkillb
 Share

Recommended Posts

I think this is an easier way to setup an electrumx server. It's not that bad once you go through the steps. Trying to be thorough.

Install docker

My github for this.
https://github.com/buzzkillb/docker-electrumx

We will end up running denariusd in a container and electrumx in a container.

First create a folder on your server or vps to store the denarius blockchain. This can be anywhere, but lets make this easy.

cd ~
mkdir .denarius
cd .denarius
nano denarius.conf

Sample denarius.conf, pay attention as we will need the rpcuser and rpcpassword.

rpcuser=denariusrpc
rpcpassword=MAKEUPSOMEPASSWORD
maxconnections=125
rpcport=32369
port=33369
daemon=0
listen=1
server=1
discover=1
txindex=1
bind=127.0.0.1:33369

We either sync from block 0 or use chaindata. You decide.

Now we can run the denariusd docker container.

docker run \
  --net=host \
  --name=denariusd \
  -t -d \
  -p 33369:33369 \
  -p 32369:32369 \
  -v ~/.denarius:/data \
  -P buzzkillb/denariusd:latest

To check the sync

docker logs denariusd -f

ctrl+c to exit out of that whenever

Now to run electrumx server (wait to be fully sync'd).

docker run \
  --name=electrumx \
  --net=host \
  --ulimit nofile=5120:5120 \
  -t -d \
  -v ~/electrumx:/data \
  -e DAEMON_URL=http://denariusrpc:[email protected]:32369 \
  -e COIN=Denarius \
  -e DB_ENGINE=rocksdb \
  -p 50001:50001 \
  -p 50002:50002 \
  buzzkillb/docker-electrumx:latest

To watch these logs.

docker logs electrumx -f

Once running check it can be found.

openssl s_client -connect electrumx1.denarius.pro:50002

Working on an easy way to do the compaction.

If you stop the container and then run

docker run \
  --name=electrumx-compact \
  --net=host \
  --ulimit nofile=5120:5120 \
  -t -d \
  -v ~/electrumx:/data \
  -e DAEMON_URL=http://denariusrpc:[email protected]:32369 \
  -e COIN=Denarius \
  -e DB_ENGINE=rocksdb \
  -p 50001:50001 \
  -p 50002:50002 \
  buzzkillb/docker-electrumx:dcompact

This will compact the database using Denarius environment variables.

With both containers electrumx and electrumx-compact both up, we can now add a cronjob to stop server, start compact, and restart server.

crontab -e

Run daily, this is overkill. Best to run every 14 days or less.

0 0 * * * docker stop electrumx >/dev/null 2>&1
1 0 * * * docker start electrumx-compact >/dev/null 2>&1
6 0 * * * docker start electrumx >/dev/null 2>&1

 

  • Like 2
Link to comment
Share on other sites

  • 7 months later...

Updated dockerhub to latest v1.14.

To use rocksdb instead of leveldb add this to the run command for latest and dcompact under -e COIN=Denarius \

-e DB_ENGINE=rocksdb \

If in doubt do this to start over

docker stop electrumx
docker stop electrumx-compact
docker rm electrumx
docker rm electrumx-compact
rm -rf ~/electrumx

Then rerun the 2 run commands. Basically run the first, wait for full sync, then stop, run dcompact, stop and then run the first electrumx. Cronjob should take care of the rest from there.

  • Like 1
Link to comment
Share on other sites

  • 2 weeks later...
  • 2 months later...

What I wanted was to just run certbot without a webserver to get the signed keys and then stick them into the docker. Its very similar but with a couple extra steps.

First generate your certbot TLS key for your domain. You should already have changed your A record on whatever site you are using for domain records to match up to your vps IP. Cloudflare, godaddy, namecheap, afraid, etc.

Use certbot to install a standalone key without running nginx or apache.

https://certbot.eff.org/lets-encrypt/ubuntubionic-other

After this is done your keys will be in directories like this. Take note of the full path and filenames as this is what we are going to link in the docker run command.

/etc/letsencrypt/live/electrumx1.denarius.pro/fullchain.pem
/etc/letsencrypt/live/electrumx1.denarius.pro/privkey.pem

The docker run command looks like below. Basically linking the 2 host pem files directly into the container. And also passing an environment variable to pick those locations up. Original latest tag is being used.

docker run \
  --name=electrumx \
  --net=host \
  --ulimit nofile=5120:5120 \
  -t -d \
  -v ~/electrumx:/data \
  -e DAEMON_URL=http://rpcusername:[email protected]:32369 \
  -e COIN=Denarius \
  -e DB_ENGINE=rocksdb \
  -v /etc/letsencrypt/live/electrumx1.denarius.pro/fullchain.pem:/data/fullchain.pem \
  -v /etc/letsencrypt/live/electrumx1.denarius.pro/privkey.pem:/data/privkey.pem \
  -e SSL_CERTFILE=/data/fullchain.pem \
  -e SSL_KEYFILE=/data/privkey.pem \
  -e REPORT_SERVICES=ssl://electrumx1.denarius.pro:50002 \
  -e SERVICES=tcp://:50001,ssl://:50002,wss://:50004,rpc:// \
  -p 50001:50001 \
  -p 50002:50002 \
  buzzkillb/docker-electrumx:latest

Then the compaction one do something similar. Also updating this container so the compaction is just for rocksdb

docker run \
  --name=electrumx-compact \
  --net=host \
  --ulimit nofile=5120:5120 \
  -t -d \
  -v ~/electrumx:/data \
  -e DAEMON_URL=http://rpcusername:[email protected]:32369 \
  -e COIN=Denarius \
  -e DB_ENGINE=rocksdb \
  -v /etc/letsencrypt/live/electrumx1.denarius.pro/fullchain.pem:/data/fullchain.pem \
  -v /etc/letsencrypt/live/electrumx1.denarius.pro/privkey.pem:/data/privkey.pem \
  -e SSL_CERTFILE=/data/fullchain.pem \
  -e SSL_KEYFILE=/data/privkey.pem \
  -p 50001:50001 \
  -p 50002:50002 \
  buzzkillb/docker-electrumx:rocksdbcompact

mental note: Using carsens pull request while we wait for official electrumx github to update to latest tribushashm.

to renew certbot in a cronjob

crontab -e

and put this line in at the end

52 0,12 * * * root /usr/bin/certbot renew

 

  • Like 1
Link to comment
Share on other sites

For some reason the SERVICES environment variable wasn't being passed through from the Dockerfile. So I set that in the docker run itself.

  -e REPORT_SERVICES=ssl://electrumx1.denarius.pro:50002 \
  -e SERVICES=tcp://:50001,ssl://:50002,wss://:50004,rpc:// \

You can remove the tcp://:50001 to only allow ssl. Need to figure out tor next.

  • Like 1
Link to comment
Share on other sites

To test if TLS letsencrypt certificate is working. Samples below for a bash script. listunspent is using a scripthash from the D address, I will leave that up to the user's imagination how to get that.

(echo '{"method" : "blockchain.block.header", "params": ["1"], "id": "msg_id"}'; sleep 1) | ncat --ssl electrumx1.denarius.pro 50002
(echo '{"method" : "blockchain.scripthash.listunspent", "params": ["15617fccc9fd5379e5166108e217c55b54b6d9428f8a2f222221323982fe3537"], "id": "msg_id"}'; sleep 1) | ncat --ssl electrumx1.denarius.pro 50002 | jq '.'

 

Link to comment
Share on other sites

  • 5 weeks later...

I still do not understand how 1 container can be used and also compact the database. When electrumx is stopped, the container shuts down. If anyone knows please let me know.

How to getinfo from the command line outside of the docker container.

docker exec -it electrumx /electrumx/electrumx_rpc getinfo

Or get into the container itself and run commands.

docker exec -it electrumx sh

Add a peer

docker exec -it electrumx /electrumx/electrumx_rpc add_peer "electrumx1.denarius.pro v1.15 s110 t"

 

  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...