Jump to content

Recommended Posts

304

459 posts
1183 BF$

In this example the idea is to run Iquidus Block Explorer with the daemon and traefik for reverse proxy all using a single docker-compose. Hopeful if anyone else tries this they come up with some better configs for the whole thing. I am going to use Ubuntu 20.04 as the example since its latest and greatest.

image.thumb.png.268f521f55c72246d10a56ca170abfa3.png

We will be using

Install Docker and Docker Compose

#Install Docker

sudo apt install docker.io
sudo systemctl enable --now docker
sudo usermod -aG docker SOMEUSERNAME
docker --version

#Install docker-compose

sudo apt install docker-compose
docker-compose version

I would reboot at this step and make sure docker is still working. 20.04 has been a bit glitchy for me. If docker stops running, this fixed it.

rm /etc/docker/daemon.json
service docker restart
systemctl status docker.service

If you are using cloudflare, my traefik isn't setup correctly to use Cloudflare proxy and get the letsencrypt TLS certs once proxied. Will update once I get that config working.

Make your .conf file in ~/.denarius/denarius.conf (switch this for your coin, the guide is tailored to Denarius, but should be an easy swap).

denarius.conf (note daemon=0 for the docker daemon I built) - based on the docker hub image https://hub.docker.com/r/buzzkillb/denariusd iquidus branch/tag.

rpcuser=rpcuser
rpcpassword=aLongPasswordLikeThis
rpcport=32369
port=33369
daemon=0
listen=1
server=1
txindex=1
rpcallowip=*

At the your home folder clone the explorer.

cd ~
git clone https://github.com/buzzkillb/iquidusdocker explorer
cd explorer

2 things to change, go to your explorer folder inside explorer and switch logo.png to your coin logo, and edit settings.json to your coin. That's it.

sample settings.json

/*
  This file must be valid JSON. But comments are allowed

  Please edit settings.json, not settings.json.template
*/
{
  // name your instance!
  "title": "D-Explorer",

  "address": "https://explorer.example.com",

  // coin name
  "coin": "Denarius",

  // coin symbol
  "symbol": "D",

  // logo
  "logo": "/images/logo.png",

  // favicon
  "favicon": "public/favicon.ico",

  // Uses bootswatch themes (http://bootswatch.com/)
  // Valid options:
  //     Cerulean, Cosmo, Cyborg, Darkly, Flatly, Journal, Lumen, Paper,
  //     Readable, Sandstone, Simplex, Slate, Spacelab, Superhero, United, Yeti
  // theme (see /public/themes for available themes)
  "theme": "Cyborg",

  // port to listen for requests on.
  "port" : 3001,

  // database settings (MongoDB)
  "dbsettings": {
    "user": "",
    "password": "",
    "database": "explorerdb",
    "address": "mongodb",
    "port": 27017
  },

  //update script settings
  "update_timeout": 10,
  "check_timeout": 250,
  "block_parallel_tasks": 1,

  // wallet settings
  "use_rpc": true,

  "wallet": {
    "host": "denarius",
    "port": 32369,
    "username": "rpcuser",
    "password": "aLongPasswordLikeThis"
  },

  // confirmations
  "confirmations": 10,

  // language settings
  "locale": "locale/en.json",

  // menu settings
  "display": {
    "api": true,
    "markets": true,
    "richlist": true,
    "twitter": true,
    "facebook": false,
    "googleplus": false,
    "youtube": false,
    "search": true,
    "movement": true,
    "network": true
  },

  // index page (valid options for difficulty are POW, POS or Hybrid)
  "index": {
    "show_hashrate": true,
    // Show Market Cap in header
    "show_market_cap": false,
    // Show Market Cap in place of price box
    "show_market_cap_over_price": false,
    "difficulty": "Hybrid",
    "last_txs": 100,
    "txs_per_page": 10
  },

  // ensure links on API page are valid
  "api": {
    "blockindex": 1337,
    "blockhash": "000000000661c86bf89e652eb142093bd9123006f3085595dee183bfe1c24570",
    "txhash": "776684cfd496890268805a1d86d3fd00f4097c1dbffecc3acd79101c15216594",
    "address": "DABQj7yoQuvfxVVWMf2mqWhoHLDMUqUJsc"
  },

  // market settings
  //supported markets: bittrex, poloniex, yobit, empoex, bleutrade, cryptopia, ccex
  //default market is loaded by default and determines last price in header
  "markets": {
    "coin": "D",
    "exchange": "BTC",
    "enabled": ["tradeogre"],
    "tradeogre_id": "BTC-D",
    "default": "tradeogre"
  },

  // richlist/top100 settings
  "richlist": {
    "distribution": true,
    "received": true,
    "balance": true
  },
  // movement page settings
  // min amount: show transactions greater than this value
  // low flag: greater than this value flagged yellow
  // high flag: greater than this value flagged red
  "movement": {
    "min_amount": 100,
    "low_flag": 1000,
    "high_flag": 5000
  },

  // twitter, facebook, googleplus, youtube
  "twitter": "denariuscoin",
  "facebook": "yourfacebookpage",
  "googleplus": "yourgooglepluspage",
  "youtube": "youryoutubechannel",

  //genesis
  "genesis_tx": "c6d8e8f56c25cac33567e571a3497bfc97f715140fcfe16d971333b38e4ee0f2",
  "genesis_block": "00000d5dbbda01621cfc16bbc1f9bf3264d641a5dbf0de89fd0182c2c4828fcd",

  //heavy (enable/disable additional heavy features)
  "heavy": false,

  //disable saving blocks & TXs via API during indexing.
  "lock_during_index": false,

  //amount of txs to index per address (stores latest n txs)
  "txcount": 100,
  "txcount_per_page": 50,

  //show total sent & received on address page (set false if PoS)
  "show_sent_received": true,

  // how to calculate current coin supply
  // COINBASE : total sent from coinbase (PoW)
  // GETINFO : retreive from getinfo api call (PoS)
  // HEAVY: retreive from heavys getsupply api call
  // BALANCES : total of all address balances
  // TXOUTSET : retreive from gettxoutsetinfo api call
  "supply": "GETINFO",

  // how to acquire network hashrate
  // getnetworkhashps: uses getnetworkhashps api call, returns in GH/s
  // netmhashps: uses getmininginfo.netmhashpsm returns in MH/s
  "nethash": "netmhashps",

  // nethash unitd: sets nethash API return units
  // valid options: "P" (PH/s), "T" (TH/s), "G" (GH/s), "M" (MH/s), "K" (KH/s)
  "nethash_units": "G",

  // Address labels
  // example : "JhbrvAmM7kNpwA6wD5KoAsbtikLWWMNPcM": {"label": "This is a burn address", "type":"danger", "url":"http://example.com"}
  // label (required) = test to display
  // type (optional) = class of label, valid types: default, primary, warning, danger, success
  // url (optional) = url to link to for more information
  "labels": {
  //  "DDD6SzCwXSEcTPHmNwEQX6xbUs2Rf3svNX": {"label": "Cryptopia address", "type":"primary", "url":"http://disney.com"},
  //  "JSWVXHWeYNknPdG9uDrcBoZHztKMFCsndw": {"label": "Cryptsy"}
  }
}

Go back to the main explorer directory and edit docker-compose.yml

version: "3"
services:

  traefik:
    image: "traefik:v2.2"
    command:
      #- "--log.level=DEBUG"
      - "--api.insecure=true" #change to false in production
      - "--api.dashboard=true" #change to false in production
      - "--providers.docker.exposedbydefault=false"
      - "--entrypoints.web.address=:80"
      - "--entrypoints.websecure.address=:443"
      - "--certificatesresolvers.myresolver.acme.tlschallenge=true"
      #- "--certificatesresolvers.myresolver.acme.caserver=https://acme-staging-v02.api.letsencrypt.org/directory"
      - "[email protected]com"
      - "--certificatesresolvers.myresolver.acme.storage=/letsencrypt/acme.json"
    ports:
      - "80:80"
      - "443:443"
      - "8080:8080"
    volumes:
      - "./letsencrypt:/letsencrypt"
      - "/var/run/docker.sock:/var/run/docker.sock:ro" 
    restart: always
  denarius:
    image: buzzkillb/denariusd:iquidus
    volumes:
      - ~/.denarius:/data
    ports:
      - 33369:33369
      - 32369:32369
    restart: unless-stopped
  explorer:
    build: ./explorer
    stdin_open: true
    tty: true
    ports:
      - 3001:3001
    links:
      - mongodb
      - denarius
    depends_on:
      - mongodb
      - denarius
    command: /bin/bash -c "service cron start && cd /opt/iquidus && npm start"
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.explorer.rule=Host(`explorer.example.com`)"
      - "traefik.http.routers.explorer.entrypoints=websecure"
      - "traefik.http.routers.explorer.tls.certresolver=myresolver"
      - "traefik.http.services.explorer.loadbalancer.server.port=3001"
      - "traefik.http.middlewares.explorer_redirect.redirectscheme.scheme=https"
      - "traefik.http.routers.explorer_insecure.rule=Host(`explorer.example.com`)"
      - "traefik.http.routers.explorer_insecure.entrypoints=web"
      - "traef[email protected]docker"
  mongodb:
    image: mongo:latest
    container_name: "mongodb"
    environment:
      - MONGO_DATA_DIR=/data/db
      - MONGO_LOG_DIR=/dev/null
    volumes:
      - ./data/db:/data/db
    ports:
      - 27017:27017
    command: mongod --bind_ip 0.0.0.0 --logpath=/dev/null --quiet --wiredTigerCacheSizeGB 2
    restart: unless-stopped

Now run docker-compose

cd ~/explorer
docker-compose up -d

And that's about it. Check 127.0.0.1:3001 or your domain. Traefik reverse proxy will automatically pull in letsencrypt TLS certs for you, will also redirect http to https, and generally keep everything up. Traefik once setup is much more clean than using an Nginx reverse proxy. Plus the letsencrypt TLS certs are taken care of automagically so no more certbot cronjobs. This example also shows how to send traffic to port 3001. This block explorer runs heavy, so I doubt this will work on a typical single CPU, 2gb VPS.

Anytime you make a change to settings.json, rebuild like this

cd ~/explorer
docker-compose down
rerun docker-compose build
docker-compose up -d

Build this locally first in a VM, and check it works. Also 127.0.0.1:8080 is the traefik dashboard. I would turn this off in the main docker-compose.yml on the VPS/server itself once ready to setup.

While waiting for the full sync, the whole thing starts to go wild using up memory. Quick bash script to restart every 30min to cut down on potential crashing.

saveram.sh

#!/bin/bash
while true; do

docker-compose down && docker-compose up -d
sleep 1800

done

Example site I am syncing before I move to a VPS and different domain. https://explorer.denarius.guide/

  • Like 1

If you enjoy my content please consider donating to the Denarius creator - https://www.patreon.com/carsenk
Join Denarius Discord - https://discord.gg/JQEmXwb

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...