-
Notifications
You must be signed in to change notification settings - Fork 110
Using the Pocket Core Service Node Docker Image
- Having Docker available in the server machine, for installation please refer to the following link: https://docs.docker.com/install.
Remember to keep your image updated by running the following command:
docker rmi -f poktnetwork/pocket-core:mvp-latest && docker pull poktnetwork/pocket-core:mvp-latest
During this tutorial we will be using the docker run
and a series of environment variables to configure your Pocket Core Service Node. All environment variables are passed using the -e
argument of the docker run
command. For example:
docker run -e MY_VAR=myvalue -it poktnetwork/pocket-core:mvp-latest
Another argument we will be using is -p
, which allows us to map a port within the Docker container to a port in the host machine, allowing us to access the Pocket Core process running inside the container (By default on the port 8081). For example:
docker run -p 8081:8081 -it poktnetwork/pocket-core:mvp-latest
The unique identifier for all of your Service Nodes instances. This GID will be provided by the Pocket team and will serve as the primary means of authentication with the Trusted MVP Dispatch Node.
Example
POCKET_CORE_SERVICE_GID=GID1
The IP, domain, load balancer or proxy that points to your Service Node.
NOTE: In case you are hosting more than one service node and/or will expect to receive higher traffic, we suggest to set it up behind a load balancer
Example
POCKET_CORE_SERVICE_IP=yourdomain.com
Example
POCKET_CORE_SERVICE_IP=x.x.x.x
Defaults to
POCKET_CORE_SERVICE_IP=127.0.0.1
The port to be used to connect using your POCKET_CORE_SERVICE_IP
NOTE: In case you are going to production, we suggest to use 443
and setup properly HTTPS
Example
POCKET_CORE_SERVICE_PORT=443
Defaults to
POCKET_CORE_SERVICE_PORT=80
Absolute path to the data directory (defaults to datadir
)
Defaults to
datadir
Example
POCKET_PATH_DATADIR=datadir
Default request timeout (in ms) to use when doing network requests (defaults to 0
)
Defaults to
0
Example
POCKET_CORE_REQUEST_TIMEOUT=1000
In order to connect your Pocket Core instance to your blockchain nodes, you're going to need to specify a chains.json
file, which you can do in different ways:
- Fetching your
chains.json
configuration file from a S3 bucket. - Passing
chains.json
configuration via environment variable. - Mapping
POCKET_PATH_DATADIR
to a folder with yourchains.json
.
Please see the example below to see what the contents of the chains.json
file must be:
[
{
"blockchain": {
"name": "ETH",
"netid": "4"
},
"url":"mygethrinkebynode.com:443"
},
{
"blockchain": {
"name": "AION",
"netid": "32"
},
"url":"myaionmasterynode.com:80"
}
]
name
is the name of the hosted blockchain. As of now, the convention is to put the ticker of the network in uppercase (as shown above).
netid
is the network id that you are running of the specific hosted blockchain, this is used to differentiate a testnet request from a mainnet one. The convention is to use whatever identifies that specific network (e.g. 4
for Ethereum's Rinkeby testnet, 32
for AION's Mastery testnet).
url
is the url in which you are running the specified blockchain node. Make sure your Docker Container has network access to this url, if Pocket Core cannot reach it, it won't spin up. For more information on Docker Networking please refer to the following link: https://docs.docker.com/network/.
To pull your chains.json
from a S3 bucket, we will use the POCKET_CORE_S3_CONFIG_URL
environment variable described below.
Receives a URL for a S3 bucket or a S3 bucket and directory path to download configurations from. If not provided, it will lookup your configuration using the POCKET_CORE_CHAINS
environment variable. The bucket must contain a file named chains.json
.
In order to download the configuration properly from S3. You will also need to define the following environment variables by using the -e
flag of the docker run
command:
-e AWS_ACCESS_KEY_ID=xxx
-e AWS_SECRET_ACCESS_KEY=xxx
-e AWS_DEFAULT_REGION=us-east-1
Example with bucket:
POCKET_CORE_S3_CONFIG_URL=s3://mypocketconfigbucket/
Example with bucket subdirectory: sub-directory
POCKET_CORE_S3_CONFIG_URL=s3://mypocketconfigbucket/staging
Please refer to example below to see how you can run a Pocket Core Service Node using S3 to fetch your chains.json
configuration:
$ docker run
-p 8081:8081
-e POCKET_CORE_SERVICE_IP=yourservicenode.com
-e POCKET_CORE_SERVICE_PORT=443
-e POCKET_CORE_SERVICE_GID=EXAMPLE_GID
-e POCKET_CORE_S3_CONFIG_URL=s3://mypocketconfigbucket/
-e AWS_ACCESS_KEY_ID=xxx
-e AWS_SECRET_ACCESS_KEY=xxx
-e AWS_DEFAULT_REGION=us-east-1
-it poktnetwork/pocket-core:mvp-latest
Pocket Core also allows you to pass in the chains.json
contents via an environment variable described below.
Receives a JSON Array with the chains.json
information.
Defaults to
[]
Example
POCKET_CORE_CHAINS='[{"blockchain":{"name":"AION","netid":"32"},"port":"80","medium":"rpc","host":"myaionmasterynode.com"},{"blockchain":{"name":"ETH","netid":"4"},"port":"80","medium":"rpc","host":"mygethtestnetnode.com"}]'
$ docker run
-p 8081:8081
-e POCKET_CORE_SERVICE_IP=yourservicenode.com
-e POCKET_CORE_SERVICE_PORT=443
-e POCKET_CORE_SERVICE_GID=EXAMPLE_GID
-e POCKET_CORE_CHAINS='[{"blockchain":{"name":"AION","netid":"256","version":"0"},"url":"myaionmainnetnode.com"},{"blockchain":{"name":"AION","netid":"32","version":"0"},"url":"myaionmasterynode.com"},{"blockchain":{"name":"ETH","netid":"1","version":"0"},"url":"mygethmainnetnode.com"},{"blockchain":{"name":"ETH","netid":"4","version":"0"},"url":"mygethtestnetnode.com"}]'
-it poktnetwork/pocket-core:mvp-latest
Docker allows you to map a directory in the host machine to a directory in the Docker container, which you can use to map your datadir
and extract the chains.json
from there using the -v
flag. Let's take a look at the example below:
$ docker run
-u root
-p 8081:8081
-e POCKET_CORE_SERVICE_IP=yourservicenode.com
-e POCKET_CORE_SERVICE_PORT=443
-e POCKET_CORE_SERVICE_GID=EXAMPLE_GID
-v $PWD/datadir:/go/src/github.com/pokt-network/pocket-core/datadir
-it poktnetwork/pocket-core:mvp-latest
Or if you modified the data dir location using the POCKET_PATH_DATADIR
, you must use that in the -v
argument, please see the example below:
$ docker run
-u root
-p 8081:8081
-e POCKET_CORE_SERVICE_IP=yourservicenode.com
-e POCKET_CORE_SERVICE_PORT=443
-e POCKET_CORE_SERVICE_GID=EXAMPLE_GID
-e POCKET_PATH_DATADIR=my_custom_data_dir
-v $PWD/datadir:/go/src/github.com/pokt-network/pocket-core/datadir # See here the value is reflected
-it poktnetwork/pocket-core:mvp-latest
NOTE: Do not use this example in Production
this last two examples uses -u root
(run container as root) and are only just for educational purposes.
For security concerns It is NOT recommended to run any application as root