├── .gitignore ├── LICENSE ├── README.md ├── bin ├── bitcoindctl ├── electrumctl └── mainctl ├── bitcoind ├── Dockerfile ├── bitcoind.conf └── enter ├── do ├── electrum ├── Dockerfile ├── electrum.banner ├── electrum.conf └── enter └── etc └── env /.gitignore: -------------------------------------------------------------------------------- 1 | tmp/* 2 | .env 3 | data/bitcoind/* 4 | data/electrum/data/* 5 | data/electrum/leveldb/* 6 | data/electrum/cert/* -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 BinaryAge 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Docker-ized Electrum server 2 | 3 | [Electrum](http://electrum.org) is a great light-weight Bitcoin client. It connects to dozen servers provided by enthustiasts. 4 | 5 | This is an easy way how to run your own Electrum server and help to diversify Bitcoin infrastructure. 6 | 7 | # Installation 8 | 9 | #### Prerequisities 10 | 11 | * grab some VPS (tested Digital Ocean with Ubuntu 13.10) - min 30GB disk, 2GB mem 12 | * [install Docker](https://www.docker.io/gettingstarted/#h_installation) 13 | * don't worry about losing containers, all esential data will be persistent in main host filesystem 14 | * technically essential data folders will be mapped via docker volumes to `/var/lib/electrum-server-docker/*` 15 | * bitcoind's database, electrum's data, leveldb and cerificates 16 | 17 | #### Installation 18 | 19 | Following script will build and add two new containers in your docker: 20 | 21 | 1. electrum-bitcoind ([bitcoind](https://github.com/bitcoin/bitcoin) with mapped database to host's `/var/lib/electrum-server-docker/bitcoind`) 22 | 2. electrum-server ([electrum-server](https://github.com/spesmilo/electrum-server) with mapped database to host's `/var/lib/electrum-server-docker/electrum/*`) 23 | 24 | Steps: 25 | 26 | git clone git@github.com:binaryage/electrum-server-docker.git 27 | cd electrum-server-docker 28 | touch .env 29 | echo "export BITCOIND_RPC_USER=some_user" >> .env 30 | echo "export BITCOIND_RPC_PASSWORD=some_password" >> .env 31 | ./do setup 32 | ./do build 33 | ./do run 34 | 35 | Note: Inspect etc/env and see more overrides you can add to your custom .env 36 | 37 | ##### Stop 38 | 39 | ./do stop 40 | 41 | ##### Start 42 | 43 | ./do start 44 | 45 | ##### Upgrade 46 | 47 | ./do stop 48 | git pull 49 | ./do build 50 | ./do rm 51 | ./do run 52 | 53 | ## Credits 54 | 55 | * Docker is awesome! 56 | * Electrum guys rock 57 | * Inspiration from [srid's discourse-docker](https://github.com/srid/discourse-docker) 58 | 59 | [Licensed under MIT](LICENSE) -------------------------------------------------------------------------------- /bin/bitcoindctl: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | cd "$(dirname "$(readlink -f $0)")"/.. 5 | . etc/env 6 | 7 | START="\ 8 | sudo docker run 9 | -v $HOST_BITCOIND_DATA_DIR:/bitcoind/data \ 10 | -e BITCOIND_EXTERNAL_IP=$HOSTIP \ 11 | -e BITCOIND_RPC_USER=$BITCOIND_RPC_USER \ 12 | -e BITCOIND_RPC_PASSWORD=$BITCOIND_RPC_PASSWORD \ 13 | -e BITCOIND_CONFIG=$BITCOIND_CONFIG \ 14 | $DOCKER_RUN_OPTS \ 15 | " 16 | 17 | if [ "$1" = "serve" ]; then 18 | START="$START -d -p $HOST_BITCOIND_P2P_PORT:8333 -p $HOST_BITCOIND_RPC_PORT:8332 -name $BITCOIND_NODE_CONTAINER_NAME" 19 | fi 20 | if [ "$1" = "rpc" ]; then 21 | START="$START -d=false -rm -link $BITCOIND_NODE_CONTAINER_NAME:bitcoind -name $BITCOIND_RPC_CONTAINER_NAME" 22 | fi 23 | 24 | set -x 25 | exec $START binaryage/electrum-bitcoind $@ 26 | -------------------------------------------------------------------------------- /bin/electrumctl: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | cd "$(dirname "$(readlink -f $0)")"/.. 5 | . etc/env 6 | 7 | START="\ 8 | sudo docker run 9 | -link $BITCOIND_NODE_CONTAINER_NAME:bitcoind \ 10 | -v $HOST_ELECTRUM_LEVELDB_DIR:/electrum/leveldb \ 11 | -v $HOST_ELECTRUM_DATA_DIR:/electrum/data \ 12 | -v $HOST_ELECTRUM_CERT_DIR:/electrum/cert \ 13 | -p $HOST_ELECTRUM_HTTP_PORT:8081 \ 14 | -p $HOST_ELECTRUM_TCP_PORT:50001 \ 15 | -p $HOST_ELECTRUM_HTTP_SSL_PORT:8082 \ 16 | -p $HOST_ELECTRUM_TCP_SSL_PORT:50002 \ 17 | -e ELECTRUM_HOST=$ELECTRUM_HOST \ 18 | -e ELECTRUM_PASSWORD=$ELECTRUM_PASSWORD \ 19 | -e ELECTRUM_CONFIG=$ELECTRUM_CONFIG \ 20 | -e BITCOIND_RPC_USER=$BITCOIND_RPC_USER \ 21 | -e BITCOIND_RPC_PASSWORD=$BITCOIND_RPC_PASSWORD \ 22 | $DOCKER_RUN_OPTS \ 23 | " 24 | 25 | if [ "$1" = "serve" ]; then 26 | START="$START -d -name $ELECTRUM_SERVER_CONTAINER_NAME" 27 | fi 28 | 29 | set -x 30 | exec $START binaryage/electrum-server $@ -------------------------------------------------------------------------------- /bin/mainctl: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | cd "$(dirname "$(readlink -f $0)")"/.. 5 | . etc/env 6 | 7 | if [ "$1" = "" ] || [ "$1" = "--help" ]; then 8 | cat < 3 | 4 | RUN apt-get update 5 | RUN apt-get install -y wget make g++ python-leveldb libboost-all-dev libssl-dev libdb++-dev 6 | RUN wget http://sourceforge.net/projects/bitcoin/files/Bitcoin/bitcoin-0.8.6/bitcoin-0.8.6-linux.tar.gz 7 | RUN tar xfz bitcoin-0.8.6-linux.tar.gz 8 | RUN cd bitcoin-0.8.6-linux/src/src && make USE_UPNP= -f makefile.unix 9 | RUN ln -s /bitcoin-0.8.6-linux/src/src/bitcoind /bin/bitcoind 10 | 11 | ADD . /bitcoind 12 | WORKDIR /bitcoind 13 | 14 | EXPOSE 8333 15 | EXPOSE 8332 16 | 17 | ADD enter /enter 18 | RUN chmod +x /enter 19 | ENTRYPOINT ["/enter"] -------------------------------------------------------------------------------- /bitcoind/bitcoind.conf: -------------------------------------------------------------------------------- 1 | txindex=1 # needed by Electrum, see https://github.com/spesmilo/electrum-server/blob/master/README.leveldb 2 | 3 | externalip=$BITCOIND_EXTERNAL_IP 4 | 5 | # RPC is used for communication between Electrum and bitcoind 6 | rpcuser=$BITCOIND_RPC_USER 7 | rpcpassword=$BITCOIND_RPC_PASSWORD 8 | rpcallowip=* # TODO: figure out how to make this more strict 9 | 10 | # optional custom config passed via ENV 11 | $BITCOIND_CONFIG 12 | -------------------------------------------------------------------------------- /bitcoind/enter: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | if [ "$1" = "" ]; then 6 | cat < bitcoind.conf 22 | 23 | BITCOIND_PREFIX="bitcoind -conf=/bitcoind/bitcoind.conf -datadir=/bitcoind/data" 24 | 25 | if [ "$1" == "rpc" ]; then 26 | set -x 27 | exec $BITCOIND_PREFIX -rpcconnect=$BITCOIND_PORT_8332_TCP_ADDR -rpcport=$BITCOIND_PORT_8332_TCP_PORT ${*:2} 28 | elif [ "$1" == "serve" ]; then 29 | set -x 30 | exec $BITCOIND_PREFIX -printtoconsole 31 | else 32 | echo $@ | exec bash 33 | fi -------------------------------------------------------------------------------- /do: -------------------------------------------------------------------------------- 1 | bin/mainctl -------------------------------------------------------------------------------- /electrum/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:12.10 2 | MAINTAINER Antonin Hildebrand 3 | 4 | RUN apt-get update 5 | RUN apt-get install -y python-leveldb python-setuptools python-pip python-openssl git 6 | RUN pip install jsonrpclib 7 | 8 | ADD . /electrum 9 | WORKDIR /electrum 10 | 11 | RUN git clone https://github.com/spesmilo/electrum-server.git 12 | WORKDIR /electrum/electrum-server 13 | RUN chmod +x server.py 14 | 15 | RUN ln -s /electrum/electrum-server/server.py /bin/electrum-server 16 | RUN chmod +x /bin/electrum-server 17 | 18 | EXPOSE 50001 19 | EXPOSE 8081 20 | EXPOSE 50002 21 | EXPOSE 8082 22 | 23 | ADD enter /enter 24 | RUN chmod +x /enter 25 | ENTRYPOINT ["/enter"] -------------------------------------------------------------------------------- /electrum/electrum.banner: -------------------------------------------------------------------------------- 1 | Welcome to Electrum in BinaryAge! 2 | 3 | Having issues? 4 | => support@binaryage.com 5 | 6 | Want to run your own Electrum server? 7 | => http://github.com/binaryage/electrum-server-docker -------------------------------------------------------------------------------- /electrum/electrum.conf: -------------------------------------------------------------------------------- 1 | [server] 2 | host = $ELECTRUM_HOST 3 | stratum_tcp_port = 50001 4 | stratum_http_port = 8081 5 | stratum_tcp_ssl_port = 50002 6 | stratum_http_ssl_port = 8082 7 | 8 | #report_host = 9 | #report_stratum_tcp_port = 50001 10 | #report_stratum_http_port = 80 11 | #report_stratum_tcp_ssl_port = 50002 12 | #report_stratum_http_ssl_port = 443 13 | 14 | password = $ELECTRUM_PASSWORD 15 | 16 | #irc = no 17 | #irc_nick = 18 | ssl_certfile = /electrum/cert/electrum-server.crt 19 | ssl_keyfile = /electrum/cert/electrum-server.key 20 | 21 | # default backend is leveldb (pruning server) 22 | backend = leveldb 23 | datadir = /electrum/data 24 | 25 | # optional custom config passed via ENV 26 | $ELECTRUM_CONFIG 27 | 28 | [leveldb] 29 | path = /electrum/leveldb 30 | # for each address, history will be pruned if it is longer than this limit 31 | pruning_limit = 100 32 | 33 | [bitcoind] 34 | host = $BITCOIND_PORT_8332_TCP_ADDR 35 | port = $BITCOIND_PORT_8332_TCP_PORT 36 | # user and password from bitcoin.conf 37 | user = $BITCOIND_RPC_USER 38 | password = $BITCOIND_RPC_PASSWORD -------------------------------------------------------------------------------- /electrum/enter: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | if [ "$1" = "" ]; then 6 | cat < /etc/electrum.conf 21 | cp electrum.banner /etc/electrum.banner 22 | 23 | if [ "$1" == "serve" ]; then 24 | set -x 25 | electrum-server 26 | else 27 | echo $@ | exec bash 28 | fi -------------------------------------------------------------------------------- /etc/env: -------------------------------------------------------------------------------- 1 | # To override the environment variables here, add them to electrum-server-docker/.env 2 | 3 | export DOCKER_RUN_OPTS= 4 | 5 | # IP address of current host. 6 | export HOSTIP=$(/sbin/ifconfig eth0 | grep "inet addr" | awk -F: '{print $2}' | awk '{print $1}') 7 | 8 | export HOST_DATA_DIR_PREFIX="/var/lib/electrum-server-docker" 9 | export HOST_BITCOIND_DATA_DIR="$HOST_DATA_DIR_PREFIX/bitcoind" 10 | export HOST_ELECTRUM_DATA_DIR="$HOST_DATA_DIR_PREFIX/electrum/data" 11 | export HOST_ELECTRUM_LEVELDB_DIR="$HOST_DATA_DIR_PREFIX/electrum/leveldb" 12 | export HOST_ELECTRUM_CERT_DIR="$HOST_DATA_DIR_PREFIX/electrum/cert" 13 | export HOST_BITCOIND_P2P_PORT=8333 14 | export HOST_BITCOIND_RPC_PORT=8332 15 | 16 | export HOST_ELECTRUM_TCP_PORT=50001 17 | export HOST_ELECTRUM_HTTP_PORT=8081 18 | export HOST_ELECTRUM_TCP_SSL_PORT=50002 19 | export HOST_ELECTRUM_HTTP_SSL_PORT=8082 20 | 21 | export ELECTRUM_HOST=localhost 22 | export ELECTRUM_PASSWORD= 23 | 24 | export BITCOIND_RPC_USER= 25 | export BITCOIND_RPC_PASSWORD= 26 | export BITCOIND_CONFIG= 27 | 28 | export BITCOIND_NODE_CONTAINER_NAME=bitcoind-node 29 | export BITCOIND_RPC_CONTAINER_NAME=bitcoind-rpc 30 | export ELECTRUM_SERVER_CONTAINER_NAME=electrum-server 31 | export ELECTRUM_CONFIG= 32 | 33 | # Overrides. 34 | if [ -e .env ]; then 35 | source .env 36 | fi --------------------------------------------------------------------------------