Giter VIP home page Giter VIP logo

bcoin-docker's Introduction

Bcoin on Docker

Start up a bcoin node quickly using Docker. Pulls latest bcoin version from github and starts full node.

By default, persists data in user home directory at ~/.bcoin.

How To Use

Copy sample configurations to secrets/ directory:

Important: Be sure to keep API secrets safe.

$ mkdir -p secrets
$ cp bcoin.example.conf secrets/bcoin.conf
$ cp wallet.example.conf secrets/wallet.conf

Create bcoin network:

$ docker network create bcoin

Create nginx-proxy network:

$ docker network create nginx-proxy

Quick run, node only:

$ docker-compose up -d bcoin

Update to latest bcoin version:

$ docker-compose build --pull bcoin

HTTPS

Includes optional nginx wrapper for https. Add domain certs to secrets/certs/.

Update docker-compose VIRUAL_HOST domain setting.

See https://github.com/jwilder/nginx-proxy for more options.

Wallet HTTP

Note that Wallet and Node API servers are on separate ports. With the default docker-compose.yml configuration, Wallet API is accessible via bcoin.yourdomain.org:8334/wallet, while node endpoints are accessed through default HTTP/HTTPS ports.

Provided is a simple example of an nginx proxy to allow wallet API to be accessible on a separate domain, in order to make it unnecessary to specify wallet port.

See docker-compose.wallet.yml. (Not required to actually use wallet API)

Building

By default, docker-compose will use image pulled from purse/bcoin:latest, but you can build one yourself.

Latest is hard coded into Makefile and will need updates overtime, but you can manually pass VERSION variable to override current version.

Examples

Build v1.0.2:

  • make - Same as build
  • make build - Currently hard coded latest.
  • make latest - this will tag image as latest.
  • VERSION=v1.0.2 make build

bcoin-docker's People

Contributors

blusyn avatar boymanjor avatar gildedpleb avatar nodech avatar pinheadmz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

bcoin-docker's Issues

How to run it in SPV mode?

I've tried all of these variants in bcoin.conf:

spv: true
node-spv: true
wallet-spv: true
spv-node: true
spv-wallet: true

Include 'api-key' in bcoin.example.conf

I was having issues connecting to my local bcoin instance. I wasn't using the Nginx-proxy so I thought my connections issues had something to do with that.

My app was connecting using the Node package and the only error I was getting was "socket hung up'. After swapping to the CLI I got 'Error: Unauthorized (bad API key)'. So finally I tried copying my API key over to the configuration file that I had created in the /secrets folder.

Once that was done the rpc/http port started accepting connections as normal.

I'd suggest adding 'api-key' to bcoin.example.conf to avoid this confusion in the future.

Latest Version causes Segfault

Running this docker image with latest version of Bcoin results in a segfault when loading the ChainDB.

This has been traced back to the newest version of LevelDB/LevelDown, which appears to be incompatible with musl libc bindings inside alpine.

Currently the best solution is to use a different base OS for the docker image, one that uses standard glibc instead of musl. Arch is probably the best choice.

Error: connect ECONNREFUSED 127.0.0.1:18334

Hello guys! I've been struggling to implement this docker container in my docker-compose for a couple of days. I am able to correctly run bcoin docker container and provide it with a config file that effectively starts a bcoin node in the testnet with prune mode:

bcoin.conf:

# main, testnet
network: testnet

# Data directory
prefix: media/henry/Code/bcoin

# Enable flags
use-workers: true

log-file: true
log-level: info
max-files: 8192
prune: true

http-host: 0.0.0.0
api-key: secret123

wallet.conf

network: testnet
prefix: /media/henry/Code/bcoin
http-host: 0.0.0.0

However, when trying to commnicate with my application container, for example when trying to create a wallet like so:

	const { Network } = require("bcoin")
	const { WalletClient } = require("bclient")
	const network = Network.get("testnet")
	const walletOptions = {
		network: network.type,
		port: network.walletPort,
		apiKey: "secret123"
	}
	/**
	 * Initializes wallet from predefined mnemonic seed
	 */
	const initWallet = async () => {
		try {
			const walletClient = new WalletClient(walletOptions)
			const id = "primary"
			const wallet = walletClient.wallet(id)
			return wallet
		} catch (e) {
			throw new Error(e)
		}
	}
	const wallet = await initWallet()
	/**
	 * Adds a new account to the bcoin wallet
	 * @param {*} req 
	 * @param {*} res 
	 */
	const addUserAccount = async (req, res) => {
		const id = req.body.userId.split("|")[1]
		try {
			const userAccount = await wallet.createAccount(id)
			return userAccount
		} catch (e) {
			throw new Error(e)
		}
	}

	addUserAccount({ body: { userId: "auth0|23534576457" } })

I get a econnrefused error:

 Error: connect ECONNREFUSED 127.0.0.1:18334
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1191:14)

Here's my docker-compose (I just copied and pasted it from this repo and added my own application container to the network:

version: '2'
services:
  bitcoin-service:
    build: .
    env_file:
      - .env
    container_name: "bitcoin-service"
    ports: 
      - "8200:8200"
      - "8201:8201"
    networks:
      - "bcoin"
      - "nginx-proxy"
    volumes:
      - .:/usr/src/app
      - /usr/src/app/node_modules/
  bcoin:
    image: purse/bcoin
    container_name: bcoin
    restart: unless-stopped
    ports:
      #-- Mainnet
      # - "8333:8333"
      # - "8332:8332" # RPC/HTTP
      # - "8334:8334" # Wallet
      #-- Testnet
      - "18333:18333"
      - "18332:18332" # RPC/HTTP
      - "18334:18334"
    environment:
      BCOIN_CONFIG: /data/bcoin.conf
      VIRTUAL_HOST: bcoin.domain.com
      # VIRTUAL_PORT: 8332
      VIRTUAL_PORT: 18332 # Testnest
    networks:
      - "bcoin"
      - "nginx-proxy"
    volumes:
      - ~/.bcoin:/data
      - ${PWD}/secrets/bcoin.conf:/data/bcoin.conf
      - ${PWD}/secrets/wallet.conf:/data/wallet.conf

  nginx_proxy:
    image: jwilder/nginx-proxy
    container_name: nginx
    restart: unless-stopped
    ports:
      - "80:80"
      - "443:443"
    networks:
      - "nginx-proxy"
    volumes:
      - ./secrets/certs:/etc/nginx/certs:ro
      - /var/run/docker.sock:/tmp/docker.sock:ro

networks:
  bcoin:
    external:
      name: "bcoin"
  nginx-proxy:
    external:
      name: "nginx-proxy"

Any pointers or advice to solve this problem? Documentation is rather scarce but I really want to use bcoin as it makes it a lot easier to manage our business logic.

Docker image is not starting

I am following docker installation and getting following error and image is not starting

batman@batmobile:~/bcoin/bcoin-docker$ sudo docker logs 82a7f49e1921
/code/bcoin/node_modules/bcfg/lib/config.js:140
throw e;
^

Error: EISDIR: illegal operation on a directory, read
at Object.readSync (fs.js:489:3)
at tryReadSync (fs.js:328:20)
at Object.readFileSync (fs.js:365:19)
at Config.open (/code/bcoin/node_modules/bcfg/lib/config.js:136:17)
at new Node (/code/bcoin/lib/node/node.js:47:19)
at new FullNode (/code/bcoin/lib/node/fullnode.js:36:5)
at Object. (/code/bcoin/bin/node:24:14)
at Module._compile (internal/modules/cjs/loader.js:689:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
at Module.load (internal/modules/cjs/loader.js:599:32)
/code/bcoin/node_modules/bcfg/lib/config.js:140
throw e;
^

Error: EISDIR: illegal operation on a directory, read

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.