Skip to content
This repository has been archived by the owner on Oct 4, 2019. It is now read-only.

Build instruction

Andrew Falaleev edited this page Sep 13, 2018 · 34 revisions

Introduction

We ship a Dockerfile in project to simplify the process of building and running of golosd. If you want to build golosd without docker your OS should be Ubuntu 16.04. There is no a simple way to build golosd under any other version of Linux.

Attention

PLEASE, DON'T FORGET TO SAVE YOUR PRIVATE KEY

On upgrade time you can disable signing of blocks by witness: https://golos.io/ru--golos/@vik/ustanovka-i-nastroika-rezervnykh-nod-vozmozhnost-obkhoditsya-bez-nikh-ne-narushaya-rabotu-golosa

Stop and remove the previous version of golosd

Before starting of the new version of golosd, you should stop and remove the previous version of golosd

docker stop golos-default
docker rm golos-default

Prepare configuration for a docker image

You should clone the golosd repository, create base directories and modify configuration files.

# Clone the repository:
git clone https://github.com/GolosChain/golos.git
cd golos

# Create a directory for configuration files:
sudo mkdir -p /etc/golosd

# Copy config files to the /etc directory:
sudo cp share/golosd/seednodes /etc/golosd/
sudo cp share/golosd/config/config.ini /etc/golosd/

# Create directory for the blockchain:
sudo mkdir -p /var/lib/golosd/

# Copy the initial genesis file for the blockchain:
sudo cp share/golosd/snapshot5392323.json /var/lib/golosd/

Repository contains several configuration files, you may use them as skeleton:

You may modify the following settings:

  • witness - witness account name (for a witness node)
  • private-key - active private key (for a witness node)
  • plugins - if you don't need some of them you can remove one.

Run docker-image from GolosCore

Before running the latest version of golosd you should remove the previous version of docker image:

sudo docker image rm goloschain/golos:latest

To run the lastest version of golosd, execute the following command:

sudo docker run -d \
    -p 4243:4243 \
    -p 8090:8090 \
    -p 8091:8091 \
    -v /etc/golosd:/etc/golosd \
    -v /var/lib/golosd:/var/lib/golosd \
    --name golos-default  goloschain/golos:latest

Replaying of the blockchain

If you have the blockchain (two files /var/lib/golosd/blockchain/block_log and /var/lib/blockchain/block_log.index) you may start replaying, because it is much faster than resyncing from a network.

To start replaying you should run an additional container:

# Make sure that default container is stopped:
sudo docker ps | grep golos-default

# Stop container if it is running:
sudo docker stop golos-default

# Create container which will replay the blockchain:
sudo docker run -d \
    --env STEEMD_EXTRA_OPTS=--replay-blockchain \
    -v /etc/golosd:/etc/golosd \
    -v /var/lib/golosd:/var/lib/golosd \
    --name golos-replaying  goloschain/golos:latest
    
# To see the progress:
sudo docker logs --tail 10 -f golos-replaying

# Wait finishing ... , and stop the container and remove one:
sudo docker stop golos-replaying
sudo docker rm golos-replaying

# Replaying is complete, now you can run normal golosd:
sudo docker run -d \
    -p 4243:4243 \
    -p 8090:8090 \
    -p 8091:8091 \
    -v /etc/golosd:/etc/golosd \
    -v /var/lib/golosd:/var/lib/golosd \
    --name golos-default  goloschain/golos:latest

Building of your own docker image

Before building of your own docker image do the step with preparing of configuration.

You may build your own docker image.

Building of a docker container is quite simple.

# Remove the old image:
sudo docker image rm local/golos

# Build the new image (chose Dockerfile which you need):
sudo docker build -t local/golos -f Dockerfile .

# Run the docker container:
sudo docker run -d \
    -p 4243:4243 \
    -p 8090:8090 \
    -p 8091:8091 \
    -v /etc/golosd:/etc/golosd \
    -v /var/lib/golosd:/var/lib/golosd \
    --name golos-default  local/golos

Get logs from the docker container

sudo docker logs --tail 10 -f golos-default

Run the cli_wallet in the docker container

sudo docker exec -ti golos-default \
    /usr/local/bin/cli_wallet \
    --wallet="/var/lib/golosd/wallet.json" \
    --server-rpc-endpoint="ws://127.0.0.1:8091"

Attach to the docker container

sudo docker exec -ti golos-default /bin/bash

Stop the docker container

sudo docker stop golos-default

Start the docker container

sudo docker start golos-default

Build from sources (upgrade from the previous version of golosd).

The following instruction is actual only for Ununtu 16.04.

# Clone source code from github:
git clone https://github.com/GolosChain/golos.git
cd golos
git submodule update --init --recursive -f

# Configure the project:
mkdir build
cd build
cmake \
    -DCMAKE_BUILD_TYPE=Release \
    -DBUILD_GOLOS_TESTNET=FALSE \
    -DBUILD_SHARED_LIBRARIES=FALSE \
    -DLOW_MEMORY_NODE=FALSE \
    -DCHAINBASE_CHECK_LOCKING=FALSE \
    ..

# Build project and install the daemon to /usr/local/:
make -j $(nproc)
sudo make install

Before starting the new version of golosd, you should get config-file share/golosd/config/config.ini and set values for:

  • witness - account name of witness (for a witness node)
  • private-key - active private key (for a witness node)
  • plugins - if you don't need some of them you can remove one.

As an example, you can get the minimal list of plugings for witness-node from the following file: share/golosd/config/config_witness.ini.

After that you should stop the previous version of the daemon and replay the blockchain:

# Stopping of your daemon depends on your configuration. 
# For example, if it's a simple running application: pkill -15 golosd
# For runit: sudo sv stop golosd

# Now, you can replay the blockchain from the block_log 
# without resyncing from a network:
/usr/local/bin/golosd --replay-blockchain

Build from sources (new installation).

The following instruction is actual only for Ununtu 16.04.

# Install required packages:
sudo apt-get install -y \
        autoconf \
        automake \
        autotools-dev \
        bsdmainutils \
        build-essential \
        cmake \
        doxygen \
        git \
        ccache\
        libboost-all-dev \
        libreadline-dev \
        libssl-dev \
        libtool \
        ncurses-dev \
        pbzip2 \
        pkg-config \
        python3 \
        python3-dev \
        python3-pip \
        runit
sudo pip3 install gcovr

# Clone source code from github:
git clone https://github.com/GolosChain/golos.git
cd golos
git submodule update --init --recursive -f

# Configure the project:
mkdir build
cd build
cmake \
    -DCMAKE_BUILD_TYPE=Release \
    -DBUILD_GOLOS_TESTNET=FALSE \
    -DBUILD_SHARED_LIBRARIES=FALSE \
    -DLOW_MEMORY_NODE=FALSE \
    -DCHAINBASE_CHECK_LOCKING=FALSE \
    ..

# Build project and install the daemon to /usr/local/:
make -j $(nproc)
sudo make install

# Ok. Now, we should configure environment for the golosd.

# Create user for daemon:
sudo useradd -s /bin/bash -m -d /var/lib/golosd golosd

# Copy the genesis initial file for the blockchain:
sudo cp ../share/golosd/snapshot5392323.json /var/lib/golosd/

# Copy config files to the /etc directory:
sudo mkdir -p /etc/golosd
sudo cp ../share/golosd/seednodes /etc/golosd/
sudo cp ../share/golosd/config/config.ini /etc/golosd/
sudo chown golosd:golosd -R /etc/golosd/

# Create a service file for the daemon:
sudo mkdir -p /etc/service/golosd
sudo cp ../share/golosd/golosd.sh /etc/service/golosd/run
sudo chmod +x /etc/service/golosd/run

# The golosd can be started:
sudo sv start golosd