Published 9 June 2019

Using Credits blockchain software in Docker

Description

Description

The purpose of this article is to demonstrate the use of Docker and Credits software. Credits software consists of configuration files and the three modules: Desktop Wallet app (user wallet), contract-executor (execution of smart contracts), and node module.

In the Docker container we will use Desktop Wallet app and contract-executor.

Components

Components

Docker is software for automating deployment and application management in a virtualization environment at the operating system level. Allows you to "package" the application with all its environment and dependencies in a container that can be ported to any Linux system, as well as providing a container management environment.

Portainer is the most popular web interface for working with Docker hosts and Docker Swarm clusters. Is launched by deploying a Docker image that is passed address/socket of the Docker host as a parameter. Allows you to manage containers, images (can pick them up from Docker Hub), networks, volumes.

Installing components

Installing components

Docker

Installation in Windows. Download page.

Installation on Linux is done using the Advanced Packaging Tool (apt). Installation commands:

sudo apt-get update

sudo apt-get install \
   apt-transport-https \
   ca-certificates \
   curl \
   software-properties-common

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

sudo apt-key fingerprint 0EBFCD88

sudo add-apt-repository \
  "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
  $(lsb_release -cs) \
  stable"

sudo apt-get update

sudo apt-get install docker-ce

Portainer

The installation is the same on both operating systems, except on Linux you must add the sudo command:

Windows:

docker volume create portainer_data
docker run -d -p 9000:9000 -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer

Linux:

sudo docker volume create portainer_data
sudo docker run -d -p 9000:9000 -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer

Assembly source code

Assembly. Source code

There are 2 Docker images of builds available on GitHub.

Those are builds for credits_docker_mainnet and credits_docker_testnet

Builds should be assembled on Linux. Assembly was tested on Ubuntu 18.04.

Structure:

common (this folder contains files that’ll be in the container)

clean_test_db.sh (clears DB folder)

clean_test_keys.sh (clears folder with user keys)

run.sh (launches the node and executor)

source

runner.cpp (source code to launch node and executor)

Dockerfile (source code of build image assembler)

build.sh (image assembler)

clean.sh (cleans results of the assembler)

run.sh (launch the container) .

Step by Step image assembly

Step by Step image assemblyreating a Dockerfile script file and image

Step 1

Download Docker image for MainNet

git clone https://github.com/CREDITSCOM/Examples

next use the folder credits_docker_mainnet

Download Docker image for TestNet

git clone https://github.com/CREDITSCOM/Examples

next use the folder credits_docker_testnet

Step 2

run ./build.sh which will initiate image assembly process. Below are the beginning of the said process and its successful completion:

Assembly results:

here we get credits_test:4.2.412.3

MainNet assembly is executed in the same way: results are below:

here we get credits_mainnet:4.2.410

Launching the container from the created image from the local repository

Launching the container from the created image from the local repository

Note: By launching on Linux sudo command should be added.

File build.sh contains examples of launching the container:

running the interpreter bash in interactive mode(for TestNet)

sudo docker run -it -p 6000:6000 -p 9090:9090 --mount source=test_db,target=/credits/test_db --mount source=test_keys,target=/credits/test_keys credits_testnet:4.2.412.3 bash

Running the node in interactive mode from the local repository (for TestNet)

sudo docker run -it -p 6000:6000 -p 9090:9090 --mount source=test_db,target=/credits/test_db --mount source=test_keys,target=/credits/test_keys credits_testnet:4.2.412.3

Running the node in interactive mode from Docker repository (description is below)

sudo docker run -it -p 6000:6000 -p 9090:9090 --mount source=main_db,target=/credits/main_db --mount source=main_keys,target=/credits/main_keys pvl1175/credits_mainnet:4.2.412.3

Publishing an image to the Docker repository

Publishing an image to the Docker repository

docker tag local-image:tagname new-repo:tagname

docker push new-repo:tagname

TestNet (Example)

docker tag credits_testnet:4.2.412.3 pvl1175/credits_testnet:4.2.412.3

docker push pvl1175/credits_testnet:4.2.412.3

MainNet (Example)

docker tag credits_mainnet:4.2.410 pvl1175/credits_mainnet:4.2.410

docker push pvl1175/credits_mainnet:4.2.410

Currently Docker repository contains the following:

https://hub.docker.com/r/pvl1175/credits_testnet

https://hub.docker.com/r/pvl1175/credits_mainnet

Examples of launching on Linux and Windows from Docker repository (TestNet)

Examples of launching on Linux and Windows from Docker repository (TestNet)

Linux

sudo docker run -it -p 6000:6000 -p 9090:9090 --mount source=test_db,target=/credits/test_db --mount source=test_keys,target=/credits/test_keys pvl1175/credits_testnet:4.2.412.3

Windows

docker run -it -p 6000:6000 -p 9090:9090 --mount source=test_db,target=/credits/test_db --mount source=test_keys,target=/credits/test_keys pvl1175/credits_testnet:4.2.412.3

Clearing DB and user keys

Clearing DB and user keys

Should be accessed in interactive mode

sudo docker run -it -p 6000:6000 -p 9090:9090 --mount source=test_db,target=/credits/test_db --mount source=test_keys,target=/credits/test_keys credits_testnet:4.2.412.3 bash

then execute the following commands:

clean_test_db.sh

clean_test_keys.sh

cancel this mode with the command below:

exit

 

 

 

 

 

 

 

 

 

 

 

 

Votes 0, average rating 0

Contents