We believe your privacy is very important. We use cookies to track your behaviour and provide a better experience
Backend Helpers | Automation and Software Development for Cloud Applicationses
Bitcoin protocol is compounded from a set of different technologies. Each technology has a particular functionality that implements one more concepts about cryptography, distributed systems, consensus algorithms, and so on. This post shows how to compile the source code of the referent client known as Bitcoin Core using Alpine Linux and Docker.
The following Link contains the instructions for install docker in case you do not have it already in your system.
Bitcoin is a very complex system has too many configuration parameters. A full configuration example can be found at this link. We will use a reduced version of the configuration file. To do this, we need to create a file named bitcoin.conf
and copy the following configuration parameters:
server=1 keypool=1000 testnet=0 rpcauth=alice:c36d66fce611afc562db21c5798ddc89$ae58c4c45ae887b63b308d7e283a15fa230ab4ccfa00778ea88076cf8c66aff0 listen=1 rpcport=8332 rpcconnect=127.0.0.1 maxconnections=2 shrinkdebugfile=1
Create a file named build_bitcoin_core.sh
and copy the following instructions to that file for cloning the bitcoin code and generating the build:
#/bin/sh
cd /src
git clone https://github.com/bitcoin/bitcoin.git
cd bitcoin
./autogen.sh
./configure --with-incompatible-bdb --with-gui=no
make
make install
Create a file named Dockerfile
and copy the following code:
FROM alpine:latest
MAINTAINER Backend Helpers <info@backendhelpers.co>
USER root
ENV GIT_SSH=/tmp/ssh
ENV GIT_TRACE=1
RUN apk add --update alpine-sdk
RUN apk add --no-cache gcc git libffi musl-dev libffi-dev autoconf automake
RUN apk add --no-cache openssh-client make db-dev openssl openssl-dev
RUN apk add --no-cache boost boost-dev libtool libevent libevent-dev
ADD ./build_bitcoin_core.sh /
RUN /build_bitcoin_core.sh
ADD ./bitcoin.conf /bitcoin.conf
CMD ["/usr/local/bin/bitcoind" , "-conf /bitcoin.conf", "-datadir=/btdata"]
The following command will create a Docker image with the instructions provided in Dockerfile:
docker build . -t bitcoin-core
Docker containers have a very small of portion of disk that is not enough to deal with the Bitcoin protocol, nonetheless, Docker provides the concept of volume that may be used to share a directory in your local machine with the running container. The following command runs a container with a local directory attached as a volume:
docker run --rm -v /tmp/btdata:/btdata -dt bitcoin-core:latest