Difference between revisions of "Deploying the Ardor Node Docker Image"

From ArdorDocs
Jump to: navigation, search
m
 
(No difference)

Latest revision as of 13:49, 15 September 2020

Introduction

The Ardor Node Docker image allows to deploy an Ardor node as a container and to bootstrap the initial blockchain automatically. Docker is an open platform for developing, shipping, and running applications. Docker enables you to separate your applications from your infrastructure so you can deliver software quickly. With Docker, you can manage your infrastructure in the same ways you manage your applications.

Steps to launch the Ardor Node Docker Image

Installation of Docker

Docker is available on the following platforms:

  • Windows
  • Mac
  • Linux

As well as many VPS providers or cloud computing services providers offer support to docker containers. To install docker please refer to the official docker install documentation

Run the Ardor Node Docker Image

The repository is located in the following link: Ardor repository. Download the image from the docker hub with the docker command as follows:

docker pull jeluridaswiss/ardor

Once pulled, use the next command to run it locally using mainnet and bootstraping the blockchain:

docker run -p 27876:27876 -p 27874:27874 --name ardor -e INIT_BLOCKCHAIN_URL=https://www.jelurida.com/Ardor-nxt_db.zip -e INIT_ADMIN_PASSWORD=IWontTell jeluridaswiss/ardor

where:

  • -p exposes (opens) the given port
  • --name defines the local name of the container
  • -e passes an environment variable
  • The last argument is the name of the image: jeluridaswiss/ardor

In this execution, the image exposes the ports for the API mainnet port 27876 and the peer server port 27874. For tesnet it would be required to export the ports 26876 and 26874.

Environment variables

INIT_ADMIN_PASSWORD

This is a recommended setting. Set the value of this variable to some initial password. It will be used only on the first run of the container. Upon starting go to the wallet UI and use the "Node Configuration" page to modify the admin password. Remember to save the changes and start the node again.

INIT_AS_TESTNET

With each run of the container the start-up script (ardor-docker.sh) checks the existence of the conf/nxt.properties file. If it doesn't exist it creates a new one with some basic values. If the variable INIT_AS_TESTNET is defined as true the line nxt.isTestnet=true is written to the new conf/nxt.properties file.

INIT_BLOCKCHAIN_URL

If this variable is defined with a non-empty value the start-up script (ardor-docker.sh) checks the existence of either of the database directories db/nxt_db or db/nxt_test_db. If none are found it downloads the zip file pointed by the URL and unzips it into the database directory. This is designed to bootstrap the blockchain database from the usual URLs [1] or [2].

How it works

The docker image itself is very simple. It's based on the latest java image and just defines the volumes for the database and configuration directories and copies the specific start script ardor-docker.sh.

The reason for not even deploying the ardor node software when defining the image is to improve the compatibility with other containers providers, which are not persistent.

The ardor-docker.sh script takes care of starting the node with each container start. It does some checks to prepare and configure the software.

Download and installation of the Ardor software

If the file /ardor/run.sh doesn't exist the script downloads and unzips https://www.jelurida.com/ardor-client.zip. It also creates a nxt-installer.properties file to point the database directories to be inside the db directory so this directory (/ardor/db) could be exposed as a volume.

Creation of the initial nxt.properties file

If the file /ardor/conf/nxt.properties doesn't exist the script creates a new one wich opens the API port (so it's accessible from outside the container) and optionally defines using testnet and the admin password (see the environment variables).

Bootstrapping the blockchain database

If the environment variable INIT_BLOCKCHAIN_URL is defined and neither of the database directories exists then the provided URL is used to download a copy of the blockchain database.

Please notice that the check of existence is done on both the mainnet and testnet database. If you have a container and want to switch the network it would be much easier to just start a new container.